【发布时间】:2011-05-20 21:33:29
【问题描述】:
我正在使用 c# 代码将邮件发送给另一个用户。 当我在其中发送文本时它工作正常.. 现在我想发送图像,以便我发送的图像应该在他的收件箱中打开。意味着图像应该作为消息正文而不是附件.. 我正在使用代码将图像发送为:
System.Net.Mail.Attachment attach =
new System.Net.Mail.Attachment(
"C:\\Documents and Settings\\All Users\\Documents\\My Pictures\\Sample Pictures\\Winter.jpg");
Random Rgen = new Random();
attach.ContentId = Rgen.Next(100000, 9999999).ToString();
attach.ContentDisposition.Inline = true;
MailMessage m = new MailMessage();
m.From = new MailAddress("swe@gmail.com");
m.To.Add(new MailAddress("qwe@gmail.com"));
m.IsBodyHtml = true;
m.Body = "<html><body><h1>Picture</h1><br><img src='cid:" + attach.ContentId + "'></body></html>";
//m.Body = inline.ToString();
// m.Body = "<img src='cid:" + attach.ContentId + "'>";
SmtpClient client = new SmtpClient("smtp.gmail.com");
client.Credentials = new System.Net.NetworkCredential("swe@gmail.com", "swe");
client.EnableSsl = true;
client.Send(m);
但它没有将图像作为消息发送..
请帮帮我..
【问题讨论】: