
Custom Inbox handler - strange behavior
I am using the following
VBA code to provide a custom rule for my personal
inbox and a shared exchange account inbox. When mail is received, the
associated ItemAdd event is always fired for my inbox, but not for the the
other account. After certain external actions such as starting the VB 6 IDE
(existing or new blank project, then shutting down), the ItemAdd event for
the other account will
start firing. Any ideas why?
Thanks,
Bob
---------
Option Explicit
Public WithEvents gw_oMyItems As Outlook.Items
Public WithEvents gw_oCuisItems As Outlook.Items
'---------
'Initialize global object so that new items will be detected
'
Public Sub Application_Startup()
Dim oRecipient As Outlook.Recipient
'My Inbox items object
Set gw_oMyItems = Outlook.Session.GetDefaultFolder(olFolderInbox).Items
'CUIS Inbox items object
Set oRecipient = Outlook.Session.CreateRecipient("GRP CUIS Customer
Support")
oRecipient.Resolve
If oRecipient.Resolved Then
Set gw_oCuisItems =
Outlook.Session.GetSharedDefaultFolder(oRecipient, olFolderInbox).Items
End If
End Sub
'---------
'CUIS Inbox - tailored notification
'
Private Sub gw_oCuisItems_ItemAdd(ByVal Item As Object)
'Ignore non-mail items
If TypeName(Item) <> "MailItem" Then Exit Sub
'Custom handling here
End Sub
'---------
'My Inbox - tailored notification
'
Private Sub gw_oMyItems_ItemAdd(ByVal Item As Object)
'Ignore non-mail items
If TypeName(Item) <> "MailItem" Then Exit Sub
'Custom handling here
End Sub