S
Sydney
Hi all
Using Outlook 2003 vba, I am trying to intercept when new mail arrives on an
additional mailbox. I have found code that does exactly what I need however
it only works on the default mailbox. I tweaked the code from
http://www.vbforums.com/archive/index.php/t-251607.html hoping it will work
on a delegate Inbox, however it does not run automatically.
Am I wasting my time? Is this possible? ... Thanks in advance.
MY CODE:
''**WORKS WHEN RUN MANUALLY**
Private Sub Application_NewMail()
Dim oInbox As Outlook.MAPIFolder
Dim oEmail As Outlook.MailItem
Dim myNamespace As Outlook.NameSpace
Set myOlApp = CreateObject("Outlook.Application")
Set myNamespace = myOlApp.GetNamespace("MAPI")
Set myRecipient = myNamespace.CreateRecipient("Barrier Officer")
myRecipient.Resolve
If myRecipient.Resolved Then
Set oInbox = myNamespace.GetSharedDefaultFolder(myRecipient, olFolderInbox)
If oInbox.UnReadItemCount > 0 Then MsgBox "New Email!", vbOKOnly +
vbInformation
Set oInbox = Nothing
Set oNS = Nothing
End If
End Sub
Using Outlook 2003 vba, I am trying to intercept when new mail arrives on an
additional mailbox. I have found code that does exactly what I need however
it only works on the default mailbox. I tweaked the code from
http://www.vbforums.com/archive/index.php/t-251607.html hoping it will work
on a delegate Inbox, however it does not run automatically.
Am I wasting my time? Is this possible? ... Thanks in advance.
MY CODE:
''**WORKS WHEN RUN MANUALLY**
Private Sub Application_NewMail()
Dim oInbox As Outlook.MAPIFolder
Dim oEmail As Outlook.MailItem
Dim myNamespace As Outlook.NameSpace
Set myOlApp = CreateObject("Outlook.Application")
Set myNamespace = myOlApp.GetNamespace("MAPI")
Set myRecipient = myNamespace.CreateRecipient("Barrier Officer")
myRecipient.Resolve
If myRecipient.Resolved Then
Set oInbox = myNamespace.GetSharedDefaultFolder(myRecipient, olFolderInbox)
If oInbox.UnReadItemCount > 0 Then MsgBox "New Email!", vbOKOnly +
vbInformation
Set oInbox = Nothing
Set oNS = Nothing
End If
End Sub