List<string> to = new list<string> (); To.add ("[email protected]"); list<string> CC = new list<string> (); Cc. Add ("[email protected]"); MailMessage Message = new MailMessage (); Message.isbodyhtml = true; message.bodyencoding = Utf8encoding.utf8; message.subjectencoding = Utf8encoding.utf8; message.priority = Mailpriority.normal; Message.sender = new MailAddress ("[email protected]"); Message.subject = "Test"; Message.from = new MailAddress ("[email protected]"); for (int i = 0; i < To.count; i++) {Message.To.Add (New mailaddress (To[i])); } for (int i = 0; i < CC. Count; i++) {Message.CC.Add (New mailaddress (Cc[i])); } message.body = Genmailbody (); Add Attachment Message.Attachments.Add (new atTachment ("c:\\aa.jpg")); Set attachment type Message.attachments[0]. Contenttype.name = "Image/jpg"; Set the attachment Id message.attachments[0]. ContentId = "Ewen"; Set the attachment to inline-inline message.attachments[0]. Contentdisposition.inline = true; Set the encoding format of the attachment Message.attachments[0]. transferencoding = System.Net.Mime.TransferEncoding.Base64; SmtpClient client = new SmtpClient (); Client. Host = "Smtp.local"; Client. Deliverymethod = Smtpdeliverymethod.network; BOOL Issend = false; try {client. Send (Message); } catch (Exception E1) {//maillog (to, to, E1. Message.tostring ()); }
is mainly
Message.attachments[0]. ContentId = "Ewen"
The ID set in the mail body should correspond to the SRC in the img tag
public static string Genmailbody () { StringBuilder sb = new StringBuilder (); Sb. Append ("Dear suppliers:<br/>"); Sb. Append ("The recent Askey video, Asahi Import label, mainly due to the label serial ID code re-caused Askey can not be on the line, you are hereby notified suppliers special attention to this item!" <br/> "); Sb. Append ("If you have any questions please e-mail to [email protected], [email protected]<br/>"); Sb. Append (" "); Return SB. ToString (); }
C # send messages contain pictures