Saving an Outlook.Mailitem as a file after it has been sent (c#)

不羁的心 提交于 2020-01-17 07:51:05

问题


Based on this issue, I can save an Outlook.Mailitem object as a file when it is being sent:

..
using Outlook = Microsoft.Office.Interop.Outlook;
...
public partial class MyClass: DevExpress.XtraEditors.XtraUserControl
{
    static Microsoft.Office.Interop.Outlook.MailItem mailItem;
    ...    
    public static void SendAnOutlookMail()
    {
       ...
       mailItem.Display(false);
       ((Outlook.ItemEvents_10_Event)mailItem).Send += new Microsoft.Office.Interop.Outlook.ItemEvents_10_SendEventHandler(ThisAddIn_Send);
       ...
    };

    static void ThisAddIn_Send(ref bool Cancel)
    {
       mailItem.SaveAs(@"d:\1\sent.msg");
    }
    ...
}

My only problem is that the resulting file is an email in its state just before it has been sent (when I open it, I can press the send button on it).

My question: How could I save it in the sent state?


回答1:


the earliest you can access the item in its sent state and the sender information populated is in the Items.ItemAdd event handler on the Sent Items folder.



来源:https://stackoverflow.com/questions/45062170/saving-an-outlook-mailitem-as-a-file-after-it-has-been-sent-c

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!