This article mainly introduces the specific examples of embedded pictures in. NET, which can be referenced by friends in the following
Routine one message content call picture format is: <img src= "cid:email001" > Send the message of the service-side code: SmtpClient Send the object/code of the message omitted the code as follows: S Ystem. Net.Mail.MailMessage MailMessage = new System.Net.Mail.MailMessage (); Mailmessage.from= "sender's mailbox"; MAILMESSAGE.TO.ADD ("Recipient mailing List"); MAILMESSAGE.CC.ADD ("CC's Mailing List"); Mailmessage.subject = Subject; AlternateView htmlBody = alternateview.createalternateviewfromstring (Content,null, "text/html"); Linkedresource lrimage = new Linkedresource ("A.jpg", "image/gif"); Lrimage.contentid = "Email001"; HTMLBODY.LINKEDRESOURCES.ADD (Lrimage); MAILMESSAGE.ALTERNATEVIEWS.ADD (HtmlBody); Smtpclient.send (MailMessage); Routine two code as follows: SmtpClient SMTP = new SmtpClient (); Smtp. Deliverymethod = Smtpdeliverymethod.network; Smtp. Host = "smtp.163.com"; Smtp. Credentials = new NetworkCredential ("renzhijie1111", "* *"); MailMessage mm = new MailMessage (); Mm. from = new MailAddress ("renzhijie1111@163.com", "Invincible Zhinzhije test"); Mm. To.add ("renzhijie1990@vip.qq.com"); MM. Subject = "Sendwith picture Mail "; String plaintextbody = "If you mail client does not support HTML format, or you switch to normal text view, you will see this content"; Mm. Alternateviews.add (alternateview.createalternateviewfromstring (plaintextbody, NULL, "Text/plain")); ////html format Mail content string htmlbodycontent = "If you see <b> this </b>, you are in <span style=" color:red "> html</span> format View mail <br><br> "; Htmlbodycontent + = "<a href=" Http://www.jb51.net//%22%3EVA Entertainment network </a> <img src= "Cid:weblogo" >; /Note the image resources embedded here AlternateView HtmlBody = alternateview.createalternateviewfromstring (htmlbodycontent, NULL, " Text/html "); Linkedresource lrimage = new Linkedresource (@ "d:1.jpg", "image/gif"); Lrimage.contentid = "Weblogo"; The ContentID here corresponds to the CID in the Htmlbodycontent content: If the settings are not correct, the picture HtmlBody.LinkedResources.Add (Lrimage) is not displayed; MM. Alternateviews.add (HtmlBody); ////Request receipt of the logo mm. Headers.add ("Disposition-notification-to", "renzhijie1111@163.com"); ////Custom message header mm. Headers.add ("X-website", "http://www.jb51.net/"); &nbSp For LOTUS DOMINO SERVER, insert receipt head mm. Headers.add ("Returnreceipt", "1"); MM. Priority = Mailpriority.normal; Priority mm. ReplyTo = new MailAddress ("renzhijie1111@163.com", "Myself"); ////If the send failed, the SMTP server will send a failed message to tell me mm. Deliverynotificationoptions = deliverynotificationoptions.onfailure; ////processing Event SMTP when the asynchronous send completes. sendcompleted + = new Sendcompletedeventhandler (smtp_sendcompleted); ////begins asynchronous send SMTP. SendAsync (mm, NULL);