Outlook.Application.ItemAdd event in Outlook 2003 SP3 with Cached Exchange Mode OFF

Joined
Jun 7, 2011
Messages
1
Reaction score
0
Hi, I've been using an Interop Dll in a .NET project to keep track of when emails are sent from Outlook. However, the same problem occurs in VBA, so for simplicity I will use that:

Steps to reproduce the issue:

1) Go into Microsoft Outlook 2003 and create a new macro.

2) For the macro, enter the following code:

Sub CatchEvent()
Dim myClass As New Class1
myClass.Initialize_handler
Do
'Just loop to keep the myClass object alive
DoEvents
Loop
End Sub

3) Add a new Class Module “Class1” to the project and enter the following into it:

Dim myOutlookApp As New Outlook.Application
Public WithEvents myOutlookItems As Outlook.Items

Public Sub Initialize_handler()
' This will add an event handler which should trigger every time a new mail item is
' added to the Sent Items folder:
Set myOutlookItems = myOutlookApp.GetNamespace("MAPI").GetDefaultFolder(olFolderSentMail).Items
End Sub

Private Sub myOutlookItems_ItemAdd(ByVal Item As Object)
MsgBox ("Item Added to Sent Folder")
End Sub

You may need to reduce Outlook security to Medium or Low to get this to work.

4) Run the macro. It will attempt to add an event handler for the ItemAdd event for the Sent Items folder, and then run an endless “DoEvents” loop until either the event is fired, or you press Ctrl+Break to stop the macro, or you close Outlook.

5) Send an email from Outlook. Now the message "Item Added to Sent Folder" should appear. However, if Cached Exchange Mode is switched OFF then the message does not appear.

I've found this macro works fine in Outlook 2007 (SP2), whether Cached Exchange Mode is switched on or off. It also works fine in Outlook 2003 if Cached Exchange Mode is switched on. It's only if CEM is switched off that Outlook 2003 (SP3) has problems. I'm not sure but this could be to due with the fact we run Exchange 2010 (SP1) which does has some problems with Outlook 2003. However, we have a requirement to get this email notification facility to work in Outlook 2003 with CEM switched off (due to storage space on Terminal Servers).

I'm posting here because it might be related to the issue reported in this post: https://www.pcreview.co.uk/forums/r...nthandler-not-fired-cached-mode-t3265098.html

Any ideas? Thanks for your help
 

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