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?