How to disable the outlook.application event handler?

L

lostwings

hi sue,

Yesterday I posted the question about how to disable event handler for
outlook.items object. I think my words might not be very clear in that post.

Now I am going to make it a little bit more clear. In my COM Add-In, I have
created a subfolder under Contacts folder called "Telnet". And I want to
populate items in this folder from a Database Table, also I want to monitor
all the user "ItemAdd" events for this folder. Once the "ItemAdd" event is
raised, it will insert the user-added item(not the items populated from the
database) into the Database Table as well.

However, the Outlook.Items's ItemAdd event cannot distinguish if the newly
added item is from the user or is populated from the database table. So I
think if I can find a way to disable outlook.items 's event handler during
the Sub Populate, which is coded to populate the items under "telnet" from
the DB, and enable it once the Sub Populate finishes, that will solve the
problem for me.

I've noticed that in excel.application object there is a property called
EnableEvents. programmer can set this property to disable/enable event
handler. So is there a equivalance property for the outlook??

Thanks in Advance.
 
M

Michael Bauer

Am Wed, 23 Nov 2005 07:22:06 -0800 schrieb lostwings:

There´s no such setting in Outlook. Here comes a sample how it works:

<ThisOutlookSession>
Option Explicit
Private bDisableItemAddEvent as Boolean

Private Sub Populate()
bDisableItemAddEvent=True
' do your work
bDisableItemAddEvent=False
End Sub

Private Inbox_ItemAdd(...)
If bDisableItemAddEvent Then Exit Sub
' Handle event
End Sub
 
L

lostwings

Hi Michael,

thanks for your response. However, it seems like that your method does not
work out.

Because the private Inbox_itemAdd() event handler is always fired after the
" bDisableItemAddEvent=False" is executed in Sub Populate. So the variable
bDisableItemAddEvent still cannot disable the event handler for item added.

Any further advice? Thanks in advance.
 
M

Michael Bauer

Am Mon, 28 Nov 2005 14:25:07 -0800 schrieb lostwings:


Hi Michael,

thanks for your response. However, it seems like that your method does not
work out.

Because the private Inbox_itemAdd() event handler is always fired after the
" bDisableItemAddEvent=False" is executed in Sub Populate. So the variable
bDisableItemAddEvent still cannot disable the event handler for item added.

Any further advice? Thanks in advance.

As I´m processing my Inbox top down see my answer to your newest post.

It isn´t necessary, but makes it difficult for everyone to follow the thread
if you don´t stay within it. Usually you will get an answer within a work
day, and that doesn´t depend on how many times you´re posting the same
question.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top