VaR M = new mailmessage ();
M. From = new mailaddress ("XX ");
M. to. Add (New mailaddress ("XX "));
M. attachments. Add (new attachment (@ "E: \ downloads \ 2.jpg "));
M. attachments [0]. contentid = "mypic ";
M. attachments [0]. contentdisposition. inline = true;
M. attachments [0]. nameencoding = M. subjectencoding = M. bodyencoding = encoding. utf8;
// Add multiple attachments
M. attachments. Add (new attachment (@ "E: \ downloads \ dd.xls "));
M. attachments [0]. contentid = "mypics ";
M. attachments [0]. contentdisposition. inline = true;
M. attachments [0]. nameencoding = M. subjectencoding = M. bodyencoding = encoding. utf8;
M. Subject = "test ";
M. isbodyhtml = true;
M. body = string. format (@ " <a href =" "{0}" "target =" "_ blank" "> click a new window </a> ", "CID:" + M. attachments [0]. contentid );
VaR S = new smtpclient ();
S. enablessl = true;
S. Port = 587;
S. Host = "smtp.gmail.com ";
S. usedefacrecredentials = false;
S. Credentials = new system. net. networkcredential ("XX", "XX ");
S. Send (m );