I am trying to make it so that when an e-mail goes to the "Sent Items" box, it calls a function that will get the "Sent Date" of the e-mail. But it is not working. Here is the code of how it is being done to add the method to be called.
private void ThisAddIn_Startup(object sender, System.EventArgs e) {
try
{
Outlook.Stores stores = Application.Session.Stores;
foreach (Outlook.Store store in stores)
{
var folder = store.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
var items = folder.Items;
if (items.Count > 0)
MessageBox.Show($"Unread items in Inbox = {items.Count}");
items.ItemAdd += ItemsAdd;
}
}
catch (Exception exception)
{
Log.Error(exception.Message);
throw;
}
}
I am trying to make it so that when an e-mail goes to the "Sent Items" box, it calls a function that will get the "Sent Date" of the e-mail. But it is not working. Here is the code of how it is being done to add the method to be called.
UPDATE
I tried using the variable items as a global variable, however it keeps in theory adding the function in sent items but it does not call the function when entering something in sent items.
Code below.
Outlook.Items items;
private void ThisAddIn_Startup(object sender, System.EventArgs e) {
try
{
Outlook.Stores stores = Application.Session.Stores;
foreach (Outlook.Store store in stores)
{
var folder = store.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
items = folder.Items;
items.ItemAdd += ItemsAdd;
}
}
catch (Exception exception)
{
Log.Error(exception.Message);
throw;
}
}
