M
Mark B
VSTO, 2007, C#.
I'm going through the code of our senior developer to try and reduce the
load-time of the Outlook Add-on.
I see he is adding an event handler to all email items on ThisAddIn_Startup
so he can detect when an email is read. (He uses this info for something
else we need). It all works fine but I have noticed in testing it gets
pretty slow as more emails are stored in Outlook. I've got around 50 and the
delay is too long already...
He did have one for On-Email-Send but I removed that code and put a "folder
watch" event on the SentItems folder instead.
I am just trying to think of any way I can do something similar or an
alternative for detecting if an email is read. Any ideas?
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
.....
Outlook.Stores stores =
Globals.ThisAddIn.Application.GetNamespace("MAPI").Stores;
foreach (Outlook.Store store in stores)
{
foreach (Outlook.Folder f in store.GetRootFolder().Folders)
{
foreach (object i in f.Items)
{
if (i != null && i is Outlook.MailItem)
{
EmailsEventHandler.AddHandlers((Outlook.MailItem)i);
}
}
}
}
.....
}
public static bool AddHandlers(Outlook.MailItem mail)
{
bool result = true;
readEventHandlers.Add(new EmailReadEventHandler(mail));
return result;
}
I'm going through the code of our senior developer to try and reduce the
load-time of the Outlook Add-on.
I see he is adding an event handler to all email items on ThisAddIn_Startup
so he can detect when an email is read. (He uses this info for something
else we need). It all works fine but I have noticed in testing it gets
pretty slow as more emails are stored in Outlook. I've got around 50 and the
delay is too long already...
He did have one for On-Email-Send but I removed that code and put a "folder
watch" event on the SentItems folder instead.
I am just trying to think of any way I can do something similar or an
alternative for detecting if an email is read. Any ideas?
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
.....
Outlook.Stores stores =
Globals.ThisAddIn.Application.GetNamespace("MAPI").Stores;
foreach (Outlook.Store store in stores)
{
foreach (Outlook.Folder f in store.GetRootFolder().Folders)
{
foreach (object i in f.Items)
{
if (i != null && i is Outlook.MailItem)
{
EmailsEventHandler.AddHandlers((Outlook.MailItem)i);
}
}
}
}
.....
}
public static bool AddHandlers(Outlook.MailItem mail)
{
bool result = true;
readEventHandlers.Add(new EmailReadEventHandler(mail));
return result;
}