MailMessage email = new MailMessage();
SmtpClient smtp = new SmtpClient(smtpServer);
...
...
1.配置附件
//添加附件
email.Attachments.Add(new Attachment("C:\\img\\ewen.gif"));
//配置附件类型
email.Attachments[0].ContentType.Name = "image/gif" ;
//设置附件ID,邮件正文会用到
email.Attachments[0].ContentId = "ewen";
//设置是否内联
email.Attachments[0].ContentDisposition.Inline = true;
//设置编码格式
email.Attachments[0].TransferEncoding = System.Net.Mime.TransferEncoding.Base64;
...
...
...
2.邮件正文
string mailBody = "这里显示图片:<br><img alt='图片' src=cid:ewen>";
...
smtp.Send(email);