I did two different implementations to solve my problem, which is: I need that when an email is sent, it calls a function that with it I can get The Sent Date. Both implementations work, not 100% but they work.
private void ThisAddIn_Startup(object sender, System.EventArgs e) {
//First implementation.
try
{
Outlook.Stores stores = Application.Session.Stores;
foreach (Outlook.Store store in stores)
{
var folder = store.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderSentMail);
items = folder.Items;
items.ItemAdd += ItemsAdd;
}
}
catch (Exception exception)
{
Log.Error(exception.Message);
throw;
}
//Second implementation.
this.Application.ItemSend += new Microsoft.Office.Interop.Outlook.ApplicationEvents_11_ItemSendEventHandler(Application_ItemSend);
}
First implementation: With it I can return the correct Sent Date, however it is not working with all types of emails that are being used in the Outlook App, for example, I have my microsoft email that works with it, and a business email that was connected as POP3 and with this account does not work.
Second implementation: It works with all types of e-mails but gets the wrong Sent Date.
Is there a solution in the first implementation to work with accounts connected as POP3? or another implementation that solves my problem?
Translated with www.DeepL.com/Translator (free version)