I have an Outlook Add-in with two ribbons (for read mail and compose mail).
I created an event to get an email when it goes to the sent items after it has been send.
This is my ThisAddIn.cs
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
OutlookApplication = Application as Outlook.Application;
OutlookInspectors = OutlookApplication.Inspectors;
OutlookInspectors.NewInspector +=
new Outlook.InspectorsEvents_NewInspectorEventHandler(OutlookInspectors_NewInspector);
var sentBoxItems =
this.Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderSentMail).Items;
sentBoxItems.ItemAdd +=
new Outlook.ItemsEvents_ItemAddEventHandler(Items_ItemsAdd);
}
private void Items_ItemsAdd(object Item)
{
if (Item != null)
Helpers.SaveMailSent((Outlook.MailItem)Item); // Here do stuff to save mail
}
I tried to get the event when the "Send" button is clicked, but the mailItem goes to null.
Now I am trying to get when a new mail is sent and it goes to the sent folder.
The problem is that the event is not firing every time a mail is sent (sometimes it executes, but sometimes no)