如何使用c#将收到的邮件作为附件附加到新邮件中

How to attach a received mail as an attachment to a new mail using c#

我有一个 (Microsoft.Office.Interop.Outlook.MailItem mail) 邮件对象。
我希望将此邮件作为附件附加到另一封邮件。
但无法找到任何 solution.So 任何人都可以帮忙。

我创建了另一个邮件对象,如下所示: Microsoft.Office.Interop.Outlook.MailItem toSendMail = this.Application.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);

获取邮件,应将其添加为附件。 然后调用 «SaveAs({filename}, Microsoft.Office.Interop.Outlook.OlSaveAsType.olMSG)» 并将此文件添加到您的新邮件

根据您的要求,您希望将现有邮件对象作为附件发送到 outlook 中的另一封邮件。

执行此操作的一种方法是将现有的邮件项目保存为其他邮件的附件。试试这个:

private void AddMessageAsAttachment(Microsoft.Office.Interop.Outlook.MailItem 
                     mailContainer,Microsoft.Office.Interop.Outlook.MailItem mailToAttach)
        {
            Microsoft.Office.Interop.Outlook.Attachments attachments = null;
            Microsoft.Office.Interop.Outlook.Attachment attachment = null;
            try
            {
                attachments = mailContainer.Attachments;
                attachment = attachments.Add(mailToAttach,
                   Microsoft.Office.Interop.Outlook.OlAttachmentType.olEmbeddeditem, 1, "The attached e-mail");
                mailContainer.Save();
            }
            catch (Exception ex)
            {
                    Console.WriteLine(ex.Message);
            }
            finally
            {
                if (attachment != null) Marshal.ReleaseComObject(attachment);
                if (attachments != null) Marshal.ReleaseComObject(attachments);
            }
        }

参考:https://www.add-in-express.com/creating-addins-blog/2011/08/12/how-to-add-existing-e-mail-message-as-attachment/