HTML附件仅适用于使用Outlook应用程序(非默认邮件应用程序)上的用户使用纯文本



我们有一个C#函数,该函数使用streamwriter从ASPX文件创建HTML附件。这会生成带有HTML附件的电子邮件并发送给用户,此附件在所有Android设备和iPhone默认邮件应用程序上都显示良好。但是,用户发现在尝试使用Outlook应用程序在iPhone上打开时,它变成了纯文本。

附件在所有桌面设备(Gmail,Outlook等(上正确打开

它还可以在iPhone默认邮件应用程序上使用,并确认仅使用Outlook应用程序失败。

我们还将文件下载到PC上,然后将其转发回带有Outlook的iPhone,根本不更改文件,并且效果很好。

//Only relevant code below
HttpContext.Current.Server.Execute(path, writer);
//path is filepath of aspx file
string msg = writer.ToString();
//filename is the html file
using (StreamWriter sw = new StreamWriter(filename,true)){
sw.write(msg);
sw.Dispose();
}
mail.Attachments.Add(new Attachment(filename));

因此,事实证明,进一步的研究更深入地,我发现我们仍然有一条先前版本的行,该行将其直接放入身体时迫使纯文本。奇怪的是,只有iPhone上的Outlook应用实际上受到了影响。

//OLD:
contentType.MediaType = System.Net.Mime.MediaTypeNames.Text.Plain;
//NEW:
contentType.MediaType = System.Net.Mime.MediaTypeNames.Text.Html;

最新更新