R
R
Hi again
Is it possible to trigger an event on a delegates non default folder?
I am trying to monitor when items are added in an additional mailbox folder
(not an outlook default folder).
I tried to expand on my last code posted here but am stuck again. After
searching outlookcode.com I found an article that may contain what I need
however the link is broken ( http://www.outlookcode.com/d/quarexe.htm )
Can someone please direct me? Many thanks.
MY CODE:
Private WithEvents oFolder As Items
Private Sub Application_Startup()
Dim objNS As NameSpace
Dim myRecipient As Outlook.Recipient
Dim oFolder As Outlook.MAPIFolder
Set objNS = Application.GetNamespace("MAPI")
Set myRecipient = objNS.CreateRecipient("Barrier Officer") 'added
myRecipient.Resolve 'added
' instantiate objects declared WithEvents and get folder ID
Set oFolder =
objNS.GetFolderFromID("000000007139C0E6E9F42F4A9F4C380E252FAE020100EFA5DC80F953CF42BDA628FB9C468E630000007383EA0000")
'If oFolder.Items.Count > 0 Then MsgBox "new mail" 'used
to debug, this works
Set objNS = Nothing
End Sub
Private Sub oFolder_ItemAdd(ByVal Item As Object)
On Error Resume Next
' If Item.UnRead = True Then
' MsgBox "You have an unread item in Receipts folder"
' End If
If oFolder.Items.Count > 0 Then MsgBox "New Email in Receipts folder!",
vbOKOnly + vbInformation
Set Item = Nothing
End Sub
Is it possible to trigger an event on a delegates non default folder?
I am trying to monitor when items are added in an additional mailbox folder
(not an outlook default folder).
I tried to expand on my last code posted here but am stuck again. After
searching outlookcode.com I found an article that may contain what I need
however the link is broken ( http://www.outlookcode.com/d/quarexe.htm )
Can someone please direct me? Many thanks.
MY CODE:
Private WithEvents oFolder As Items
Private Sub Application_Startup()
Dim objNS As NameSpace
Dim myRecipient As Outlook.Recipient
Dim oFolder As Outlook.MAPIFolder
Set objNS = Application.GetNamespace("MAPI")
Set myRecipient = objNS.CreateRecipient("Barrier Officer") 'added
myRecipient.Resolve 'added
' instantiate objects declared WithEvents and get folder ID
Set oFolder =
objNS.GetFolderFromID("000000007139C0E6E9F42F4A9F4C380E252FAE020100EFA5DC80F953CF42BDA628FB9C468E630000007383EA0000")
'If oFolder.Items.Count > 0 Then MsgBox "new mail" 'used
to debug, this works
Set objNS = Nothing
End Sub
Private Sub oFolder_ItemAdd(ByVal Item As Object)
On Error Resume Next
' If Item.UnRead = True Then
' MsgBox "You have an unread item in Receipts folder"
' End If
If oFolder.Items.Count > 0 Then MsgBox "New Email in Receipts folder!",
vbOKOnly + vbInformation
Set Item = Nothing
End Sub