0

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?

Filburt
  • 17,626
  • 12
  • 64
  • 115
mma
  • 381
  • 2
  • 15

1 Answers1

2

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.

Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78
  • Thank, this solved my problem. I took the details from [here](https://stackoverflow.com/questions/12515612/event-on-item-sent-in-outlook) – mma Jul 13 '17 at 10:56