2017-06-04 53 views

回答

0

您可以使用此代碼圖像發送電子郵件:

using (var client = new SmtpClient()) 
{ 
    MailMessage newMail = new MailMessage(); 
    newMail.To.Add(new MailAddress("[email protected]")); 
    newMail.Subject = "Test Subject"; 
    newMail.IsBodyHtml = true; 

    var inlineLogo = new LinkedResource(Server.MapPath("~/Path/To/YourImage.png")); 
    inlineLogo.ContentId = Guid.NewGuid().ToString(); 

    string body = string.Format(@"     
      <img src=""cid:{0}"" /> 
     ", inlineLogo.ContentId); 

    var view = AlternateView.CreateAlternateViewFromString(body, null, "text/html"); 
    view.LinkedResources.Add(inlineLogo); 
    newMail.AlternateViews.Add(view); 

    client.Send(newMail); 
} 

https://stackoverflow.com/a/11000938/5364144

+0

一個System.InvalidOperationException異常在client.Send(NEWMAIL)存在的;如何處理它? –