This article describes how to embed the email content into an image in. net. For more information, see
The format of the image called by the mail content in routine 1 is the server code for sending the mail is: SmtpClient, the object for sending the mail, and the Code omitted is as follows: system. net. mail. mailMessage mailMessage = new System. net. mail. mailMessage (); mailMessage. from = "sender's mailbox"; mailMessage. to. add ("recipient email list"); mailMessage. CC. add ("cc Mail List"); mailMessage. subject = subject; AlternateView htmlBody = AlternateView. createAlternateViewFromString (content, null, "text/html"); required resource lrImage = new temporary resource ("a.jpg", "image/gif"); lrImage. contentId = "Email001"; htmlBody. administrative resources. add (lrImage); mailMessage. alternateViews. add (htmlBody); SmtpClient. send (mailMessage); example 2 code: 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 Ren Zhijie test"); mm. to. add ("renzhijie1990@vip.qq.com"); mm. subject = "sending emails with images"; string plainTextBody = "If your email client does not support HTML format, or you switch to the" common text "view, you will see this content"; mm. alternateViews. add (AlternateView. createAlternateViewFromString (plainTextBody, null, "text/plain"); // the content of the HTML-format email string htmlBodyContent = "if you see <B> This </B>, you can view emails in <span style = \ "color: red \"> HTML </span> Format <br> "; htmlBodyContent + = "<a href = \" http://www.jb51.net/ // % 22% 3EVA Entertainment Network </a> "; // note the image resource AlternateView htmlBody = AlternateView embedded here. createAlternateViewFromString (htmlBodyContent, null, "text/html"); required resource lrImage = new Custom Resource (@ "d: \ 1.jpg"," image/gif "); lrImage. contentId = "weblogo"; // The ContentId corresponds to the cid in the htmlBodyContent content. If the settings are incorrect, the htmlBody is not displayed. administrative resources. add (lrImage); mm. alternateViews. add (htmlBody); // indicates the receipt. mm. headers. add ("Disposition-Notification-To", "renzhijie1111@163.com"); // customize the mail header mm. headers. add ("X-Website "," http://www.jb51.net/ "); // Insert the receipt header mm for the lotus domino server. headers. add ("returnreceept", "1"); mm. priority = MailPriority. normal; // priority mm. replyTo = new MailAddress ("renzhijie1111@163.com", "Myself"); // if the sending fails, the SMTP server will send the failed email to tell me mm. deliveryNotificationOptions = DeliveryNotificationOptions. onFailure; // process event smtp when asynchronous sending is complete. sendCompleted + = new SendCompletedEventHandler (smtp_SendCompleted); // start sending smtp asynchronously. sendAsync (mm, null );