.net 发邮件

//图片将以附件方式发送
ContentType ct = new ContentType();
      ct.MediaType = MediaTypeNames.Image.Jpeg;
      Attachment data = new Attachment(filePath + "Images/email.png", ct);
      data.ContentId = "Email3";
      mail.Attachments.Add(data);

//图片插入正文中

  AlternateView htmlBody = AlternateView.CreateAlternateViewFromString(body, null, "text/html");
  string filePath = AppDomain.CurrentDomain.BaseDirectory;
  ContentType Jpeg = new ContentType();//设置文件类型
  Jpeg.MediaType = MediaTypeNames.Image.Jpeg;
  LinkedResource lrImage = new LinkedResource(filePath + "Images/11floor.jpg", Jpeg);
  lrImage.ContentId = "Email001";
  htmlBody.LinkedResources.Add(lrImage);

 
posted @ 2017-03-09 10:00  SkyLeo  阅读(153)  评论(0)    收藏  举报