0
我有一個word文檔,並使用Aspose.Word執行郵件合併,結果到內存流保存爲MHTML(我的代碼部分):mimekit前景顯示文本作爲附件
Aspose.Words.Document doc = new Aspose.Words.Document(documentDirectory + countryLetterName);
doc.MailMerge.Execute(tempTable2);
MemoryStream outStream = new MemoryStream();
doc.Save(outStream, Aspose.Words.SaveFormat.Mhtml);
然後我使用MimeKit(從的NuGet最新版本)送我的消息:
outStream.Position = 0;
MimeMessage messageMimeKit = MimeMessage.Load(outStream);
messageMimeKit.From.Add(new MailboxAddress("<sender name>", "<sender email"));
messageMimeKit.To.Add(new MailboxAddress("<recipient name>", "<recipient email>"));
messageMimeKit.Subject = "my subject";
using (var client = new MailKit.Net.Smtp.SmtpClient())
{
client.Connect(<smtp server>, <smtp port>, true);
client.Authenticate("xxxx", "pwd");
client.Send(messageMimeKit);
client.Disconnect(true);
}
當我的郵箱Web客戶端打開收到的電子郵件,我看到的文本(含圖片)和圖像作爲附件。
在Outlook(2016)中打開收到的電子郵件時,郵件正文爲空,我有兩個附件,其中1個帶有文本,1個帶有圖像。
望着MHT內容本身,它看起來像:
MIME-Version: 1.0
Content-Type: multipart/related;
type="text/html";
boundary="=boundary.Aspose.Words=--"
This is a multi-part message in MIME format.
--=boundary.Aspose.Words=--
Content-Disposition: inline;
filename="document.html"
Content-Type: text/html;
charset="utf-8"
Content-Transfer-Encoding: quoted-printable
Content-Location: document.html
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html; charset=
=3Dutf-8" /><meta http-equiv=3D"Content-Style-Type" content=3D"text/css" />=
<meta name=3D"generator" content=3D"Aspose.Words for .NET 14.1.0.0" /><titl=
e></title></head><body>
*****body removed *****
</body></html>
--=boundary.Aspose.Words=--
Content-Disposition: inline;
filename="image.001.jpeg"
Content-Type: image/jpeg
Content-Transfer-Encoding: base64
Content-Location: image.001.jpeg
****image content remove****
--=boundary.Aspose.Words=----
有一些格式或所以我必須做的就是這個在Outlook中正確顯示?或者它是由「3D」 - 找到的關鍵字引起的,如content = 3D「xxxx」,style = 3D「xxxx」?
在此先感謝。
愛德華
嗨傑弗裏,遺憾的響應晚。謝謝你的回答。我已經將FileName和ContentLocation都設置爲null,現在在Outlook中看起來很好。 – ET67