【发布时间】:2010-12-29 03:49:22
【问题描述】:
我正在使用 C# 在运行时将 Html 文档(包含图像)作为电子邮件附件发送。
但是当我检查收到的电子邮件时,发送的 html 文档不包含任何图像。
您能否指导我如何确保 html 文档与图像一起发送。
MailMessage objMailMessage = new MailMessage();
objMailMessage.From = new MailAddress("aa@gmail.com");
string[] emailIds = objReportRequest.EmailIds.Split(',');
foreach (string emailId in emailIds)
{
objMailMessage.To.Add(new MailAddress(emailId));
}
objMailMessage.IsBodyHtml = true;
objMailMessage.Body = messageBody;
objMailMessage.Subject = "Test Service";
objMailMessage.Attachments.Add(new Attachment(filePath));
SmtpClient objSmtpClient = new SmtpClient("smtp.gmail.com");
objSmtpClient.Credentials = new NetworkCredential("aaa@gmail.com", "aaa");
objSmtpClient.EnableSsl = true;
objSmtpClient.Send(objMailMessage);
我收到了 html 文档作为电子邮件附件,但没有显示图像。
谢谢!
【问题讨论】:
-
介意向我们展示您尝试使用的代码吗?
标签: c# email attachment