发送邮件,很简单的东西,主要用的就是System.Net.Mail命名空间下的东西
1 System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(); 2 message.To.Add("targetAddress"); 3 message.Subject = "This is the Subject line"; 4 message.From = new System.Net.Mail.MailAddress("sourceAddress"); 5 message.Body = "content"; 6 //附件 7 string path=@"C:\Documents and Settings\administrator\桌面\SN.txt"; 8 Attachment data = new Attachment(path, MediaTypeNames.Application.Octet);//实例化附件 9 message.Attachments.Add(data); 10 11 System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.163.com", 25); 12 smtp.Credentials = new System.Net.NetworkCredential("testID", "testPWD"); 13 smtp.Send(message);
很久没写过随笔了,今天也是需要记录一个东西,才上来写一笔的,主要是最近工作比较忙,上班没时间写,下班懒得写,于是。。就这样了,以后还是要勤快一些,尽量多写一些