static void SendMail()
{
var m = new MailMessage();
m.From = new MailAddress("youjb@xxx.com.cn");
m.To.Add(new MailAddress("youjb@xxx.com.cn"));
m.Attachments.Add(new Attachment(@"C:/Users/greystar/Desktop/江阴/IMG_1463.JPG"));
m.Attachments[0].ContentId = "MyPic";
m.Attachments[0].ContentDisposition.Inline = true;
m.Attachments[0].NameEncoding = m.SubjectEncoding = m.BodyEncoding = Encoding.UTF8;
m.Subject = "测试邮件";
m.IsBodyHtml = true;
m.Body = string.Format(@"<img src=""{0}""/><a href=""{0}"" tartget=""_bland"">点击在新窗口打开图片</a>", "cid:" + m.Attachments[0].ContentId);
var s = new SmtpClient();
s.Port = 25;
s.Host = "mail.xxx.com.cn";
s.Credentials = new System.Net.NetworkCredential("youjb@xxx.com.cn", "mypwd");
try
{
s.Send(m);
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
}