我正在使用 C#/Visual Studio 2012 创建一个电子邮件进程,该进程以原始电子邮件作为附件回复电子邮件的发件人。当处理他们发送的电子邮件时发生错误时,我会这样做。我正在使用股票 .NETSystem.Net.Mail.MailMessage
和System.Net.Mail.SmtpClient
.
我采用原始电子邮件 eml,并使用电子邮件 eml 的内容构造一个 MemoryStream:
memStream = new MemoryStream(Encoding.ASCII.GetBytes(exception.EmailEml));
memStream.Seek(0, SeekOrigin.Begin);
然后我构建了一封电子邮件并尝试添加附件,如下所示:
message.Attachments.Add(new Attachment(contentStream,
System.Net.Mime.MediaTypeNames.Text.Plain));
message.Attachments[0].Name = subject + ".msg";
在 Outlook 中,我将邮件视为附件,但 Outlook 无法打开该附件。我从 Outlook 收到一个错误...
只是设置正确的 MIME 类型以便 .MSG 附件在 Outlook 中打开,还是我需要做的其他事情?
当我在文本编辑器中查看 .msg 附件时,我在标题中看到以下内容:
Received: from server.com ([___]) by
server.com ([___]) with mapi id
___; Mon, 25 Mar 2013 23:00:20 -0400
From: Me <myemailaddy>
To: Server Side Mailbox Process <processemailaddy>
Subject: subject text
Thread-Topic: Topic text
Thread-Index: Ac4pzgz84kK07LIdQ+uIR67iWBoSxw==
Date: Mon, 25 Mar 2013 23:00:20 -0400
Message-ID:
<4B10588A111F814E992DA95C07AD4F5E0CA102@server.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Exchange-Organization-AuthAs: Internal
X-MS-Exchange-Organization-AuthMechanism: 04
X-MS-Exchange-Organization-AuthSource: server.com
X-MS-Has-Attach:
X-MS-Exchange-Organization-SCL: -1
X-MS-TNEF-Correlator:
Content-Type: text/html; charset="us-ascii"
MIME-Version: 1.0
谢谢!