我正在使用C#/ Visual Studio 2012来创建一个电子邮件流程,该流程会回复电子邮件的发件人,并将原始电子邮件作为附件。我在处理他们发送的电子邮件时发生错误时执行此操作。我正在使用股票.NET System.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类型以便在Outlook中打开.MSG附件,还是我需要做的其他事情?
当我在文本编辑器中查看.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
谢谢!
答案 0 :(得分:1)
我的不好,电子邮件来源是eml格式。我现在将文件附加到带有eml扩展的电子邮件中。在这种情况下,关键路径正在使用这种方法!