Another way to detect if email read?

Status
Not open for further replies.
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;

}
 
S

Sue Mosher [MVP]

Have you considered using the Application.ItemLoad event along with a

wrapper class to handle multiple items being loaded?

Sue Mosher

"Mark B" <none123@none.com> wrote in message

news:e5I0eJoYKHA.2164@TK2MSFTNGP02.phx.gbl...
> 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;
> }
>
 
M

Mark B

No but I wonder if that handles the email being read in the preview pane

though. Think it would? I think a lot of people just use that these days to

read emails.

"Sue Mosher [MVP]" <suemvp@gmail.com> wrote in message

news:%23vPbtNoYKHA.1640@TK2MSFTNGP06.phx.gbl...
> Have you considered using the Application.ItemLoad event along with a
> wrapper class to handle multiple items being loaded?

> > Sue Mosher
> > >

> "Mark B" <none123@none.com> wrote in message
> news:e5I0eJoYKHA.2164@TK2MSFTNGP02.phx.gbl...
> > 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;
> > }
> >


>
 
M

Mark B

Standby -- just reading your book:

http://books.google.co.nz/books?id=...e&q=outlook 2007 Application.ItemLoad&f=false

"Mark B" <none123@none.com> wrote in message

news:ugJ2XWoYKHA.1652@TK2MSFTNGP05.phx.gbl...
> No but I wonder if that handles the email being read in the preview pane
> though. Think it would? I think a lot of people just use that these days
> to read emails.

> "Sue Mosher [MVP]" <suemvp@gmail.com> wrote in message
> news:%23vPbtNoYKHA.1640@TK2MSFTNGP06.phx.gbl...
> > Have you considered using the Application.ItemLoad event along with a
> > wrapper class to handle multiple items being loaded?
>

>> > > Sue Mosher
> > >> >> >
>
>> "Mark B" <none123@none.com> wrote in message
> > news:e5I0eJoYKHA.2164@TK2MSFTNGP02.phx.gbl...
> >> 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;
> >> }
> >>

>

>>

>
 
S

Sue Mosher [MVP]

Yes, I think that's one of the reasons it was added -- to provide a better

way to handle that event.

Sue Mosher

"Mark B" <none123@none.com> wrote in message

news:ugJ2XWoYKHA.1652@TK2MSFTNGP05.phx.gbl...
> No but I wonder if that handles the email being read in the preview pane
> though. Think it would? I think a lot of people just use that these days
> to read emails.

> "Sue Mosher [MVP]" <suemvp@gmail.com> wrote in message
> news:%23vPbtNoYKHA.1640@TK2MSFTNGP06.phx.gbl...
> > Have you considered using the Application.ItemLoad event along with a
> > wrapper class to handle multiple items being loaded?
>

>> "Mark B" <none123@none.com> wrote in message
> > news:e5I0eJoYKHA.2164@TK2MSFTNGP02.phx.gbl...
> >> 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;
> >> }
> >>

>

>>

>
 
M

Mark B

Thanks for your help Sue. I've coded it now and it works well.

"Sue Mosher [MVP]" <suemvp@gmail.com> wrote in message

news:eRO341tYKHA.5640@TK2MSFTNGP06.phx.gbl...
> Yes, I think that's one of the reasons it was added -- to provide a better
> way to handle that event.

> > Sue Mosher
> > >

> "Mark B" <none123@none.com> wrote in message
> news:ugJ2XWoYKHA.1652@TK2MSFTNGP05.phx.gbl...
> > No but I wonder if that handles the email being read in the preview pane
> > though. Think it would? I think a lot of people just use that these days
> > to read emails.
>

>
>> "Sue Mosher [MVP]" <suemvp@gmail.com> wrote in message
> > news:%23vPbtNoYKHA.1640@TK2MSFTNGP06.phx.gbl...
> >> Have you considered using the Application.ItemLoad event along with a
> >> wrapper class to handle multiple items being loaded?
> >
>>> "Mark B" <none123@none.com> wrote in message
> >> news:e5I0eJoYKHA.2164@TK2MSFTNGP02.phx.gbl...
> >>> 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;
> >>> }
> >>
>>
>>>

> >


>
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
B Move emails from one account to another Outlook VBA and Custom Forms 2
R Clear one category when another is chosen Outlook VBA and Custom Forms 1
N Item cannot be saved because it was modified by another user or window, and, Item could not be moved... Using Outlook 0
e_a_g_l_e_p_i Is it possible to transfer things from one calendar to another Using Outlook 2
S Email Generated from another program and then edited sends original email. Using Outlook 2
R Time for another article on contact cards? Using Outlook 0
C Copy Outlook contact field value to another field Outlook VBA and Custom Forms 1
J Message search and edit, another way? Outlook VBA and Custom Forms 4
F Copy and replace not update contact in another pst Using Outlook 0
D Importing Outlook Categories from another domain (Exchange 2016/Outlook 2016) Using Outlook 4
B Outlook Business Contact Manager with SQL to Excel, User Defined Fields in BCM don't sync in SQL. Can I use VBA code to copy 1 field to another? BCM (Business Contact Manager) 0
R "Can't store Outlook data files under the AppData folder. Please choose another folder." Using Outlook 6
X Unable to send an email from one account to another on same PC Using Outlook 2
M Moving mail to another folder is much slower than before (Office365) Using Outlook 0
CWM030 Another Quarantine question Exchange Server Administration 0
D Any updates or fixes that would make this code stop working just moving emails to another folder Outlook VBA and Custom Forms 1
P when i move inbox mails to another folder in outlook the mail disappears Using Outlook 1
B Moving account, contacts & emails to another H/D with MSOutlook Using Outlook 5
M Shortcut to another outlook item Using Outlook 0
Sabastian Samuel HOW DO I FORWARD AN EMAIL WITH MACRO using an email that in the body of another email Outlook VBA and Custom Forms 3
P Unread Until Click Another Message? Using Outlook 2
e_a_g_l_e_p_i Another reinstall of Outlook 2010 issue Using Outlook 10
M code to move selected Outlook contacts to another folder Using Outlook 3
D Help with code to move mail on receipt to another folder based on time received Outlook VBA and Custom Forms 2
M FW Email via Outlook and another requirement Outlook VBA and Custom Forms 1
J Outlook - 2013 - Error msg when copying folders from Online Archives to another user's mailbox Using Outlook 0
Diane Poremsky Set Another Data File as Default When Using an Exchange Account Using Outlook 0
Diane Poremsky Copy New Appointments to Another Calendar using VBA Using Outlook 0
D Unable to Send On Behalf of Another User Exchange Server Administration 0
D EXPORTING MS EXCHANGE EMAILS to another platform Exchange Server Administration 10
mrmmickle1 UserProperties VBA to move message to another folder Outlook VBA and Custom Forms 7
P Office 365 manage another person's calendar Using Outlook 0
TheDavidSlight Daylight savings - another subtle bug ... Using Outlook 3
Q Outlook 2016\365 export specific rules to import in another system Exchange Server Administration 1
J Outlook 2013 how to convert 2013 OST file into an another format, i m using outlook 2013 versions. Using Outlook 1
C Custom Application Form send Email to Another User Using Outlook 1
M Copy new appointments created in multiple shared calendars to another exchange calendar Outlook VBA and Custom Forms 1
A Calling one module from another Outlook VBA and Custom Forms 2
M How to duplicate content of one field in another field? Outlook VBA and Custom Forms 3
iwshim Transfering mail from the outbox to another computer Using Outlook 0
I Outlook 2010 Replicating mixed PST/OST profile to another desktop Using Outlook.com accounts in Outlook 1
J Macro for replying to One Email with another Using Outlook 1
wallisellener Another BCM Authentication thread BCM (Business Contact Manager) 5
mikecox Forward email to another address; not with Rules Using Outlook 3
T Macro to find contacts by category and copy them to another folder Outlook VBA and Custom Forms 15
I How to block time in another calendar without invite? Using Outlook 2
Paul Butticaz Copying Contacts from SharePoint List (connected to Outlook) to another Conacts folder Using Outlook 1
P Item cannot be saved because it was modified by another user or window Using Outlook 8
Klaas "To Address" duplicated when moving msg to another folder Using Outlook 2
Britonius Delegate cannot view meetings marked Private by Another Chairperson Using Outlook 7

Similar threads

Top