如何发送包含嵌入图像的HTML正文的电子邮件? [英] How do I send an email with HTML body that has an embedded image?
本文介绍了如何发送包含嵌入图像的HTML正文的电子邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,在发送关于Outlook的电子邮件时需要帮助。电子邮件正文采用html格式,内部嵌入了图像。我的问题是,当我收到关于outlook的电子邮件时,所有图像都是断开的链接。
Hi guys, need help on sending an email on outlook. The email body is in html format and it has an embedded image inside it. My problem is when I received the email on outlook, all of the images are broken link.
public static string getEmailFile(string file)
{
//string filename = Session["filename"].ToString();
Microsoft.Office.Interop.Outlook.Application app = new Microsoft.Office.Interop.Outlook.Application();
//MailItem item = (MailItem)app.CreateItemFromTemplate(@"C:\Users\orculloj\Desktop\Sample3\" + filename, Type.Missing);
//MailItem item = (MailItem)app.CreateItemFromTemplate(@"C:\Users\orculloj\Desktop\Sample3\Test.msg", Type.Missing);
MailItem item = (MailItem)app.CreateItemFromTemplate(@"C:\Users\orculloj\Desktop\Sample2\20160101021244_5541.msg", Type.Missing);
var a = item.HTMLBody;
return a;
}
我的尝试:
What I have tried:
Outlook.Application app = new Outlook.Application();
MailItem item = (MailItem)app.CreateItemFromTemplate(@"C:\Users\orculloj\Desktop\Sample2\20160101021244_5541.msg", Type.Missing);
string from = item.ReceivedOnBehalfOfName + "@altisource.com";
//string body = item.HTMLBody;
iframe1.Attributes["src"] = "Email.aspx";
System.Net.Mail.MailMessage mailMsg = new System.Net.Mail.MailMessage();
MailAddress mailAddress = new MailAddress(from);
mailMsg.To.Add("JohnEmmanuel.Orcullo@altisource.com");
mailMsg.From = mailAddress;
// Subject and Body
mailMsg.Subject = "Testing mail..";
string x = "";
mailMsg.IsBodyHtml = true;
mailMsg.Body = getEmailFile(x);
//SmtpMail.SmtpServer = "Internal-Mail.ascorp.com";
SmtpClient smtpClient = new SmtpClient("Internal-Mail.ascorp.com");
//smtpClient.EnableSsl = true;
smtpClient.Send(mailMsg);
推荐答案
我看不到你邮件中包含图片的位置。它必须是多部分邮件,一些部分应该是图像。要在HTML部分中引用图像,您必须使用特殊的URI方案(cid :)来引用邮件部分。请查看我过去的答案:
发送HTML附件图像 [ ^ ],
我怎样才能在asp的电子邮件中发送带有文本的图像 [ ^ ],
如何在smtp邮件实现中附加文件 [ ^ ],
动态生成pdf文件并作为附件发送电子邮件。 [ ^ ]。
-SA
I don't see where you include images in your mail. It has to be multi-part mail, some parts should be images. To reference images in HTML part, you have to use the special URI scheme (cid:), to reference a mail part. Please see my past answers:
Sending HTML attachment with images[^],
how can i send image with text in email in asp[^],
How to attach a file in smtp mail implementation[^],
Dynamically generate pdf file and Send an Email as a attachment.[^].
—SA
这篇关于如何发送包含嵌入图像的HTML正文的电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文