Sent Item Event in Outlook

I use ApplicationEvents_11_ItemSendEventHandler (see http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.applicationevents_11_itemsendeventhandler.aspx ) to do some processing when an item is sent from Outlook.

However, since this event is triggered by โ€œsendingโ€ and not โ€œsendingโ€, I cannot receive certain information, such as sender, time sent, etc.

Is there an alternative event that fires after an item is sent? I read this blog post; http://easyvsto.wordpress.com/2010/07/27/how-to-save-mail-content-when-a-mail-is-sent-from-outlook/ , but I am afraid depending on the elements appearing in the folder of sent items, given that the user can disable this feature.

Edit: I have to add that I actually tried the โ€œwatch sent itemsโ€ approach and noticed that the ItemAdd event seems to fire only for the first message I sent, then not again until I restart Outlook. My code is as follows:

 var sentMail = Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderSentMail); sentMail.Items.ItemAdd += new Outlook.ItemsEvents_ItemAddEventHandler(Items_ItemAdd); 

And my method ...

 void Items_ItemAdd(object item) { MessageBox.Show(((Outlook.MailItem)item).Subject); } 
+6
source share
1 answer

If you use a modal dialog (WPF / Winforms MessageBox ), you will receive only the first event trigger. You should implement a non-blocking event handler (perhaps an element priority strategy).

Do not use modal user interface lock dialogs - Outlook will notice that the user interface is locked and ignores the start of subsequent interrupts.

See this form post for reference .


If you are concerned about user preferences for managing the repository of shipped goods, simply override them using the following snippet ...

 MailItem.DeleteAfterSubmit = false; // force storage to sent items folder (ignore user options) Outlook.Folder sentFolder = ThisAddIn.Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderSentMail); if (sentFolder != null) MailItem.SaveSentMessageFolder = sentFolder; // override the default sent items location MailItem.Save(); 
+4
source

Source: https://habr.com/ru/post/925853/


All Articles