1

Outlook Inbox Image

I would like to do some operation when a new mail comes to mailbox. For that I am using Item_Add() Event

Private Sub myOlItems_ItemAdd(ByVal Item As Object)
   ... Do Something
Exit Sub

Can anyone tell me How to set the Handler for "inbox" folder under "[email protected]"?

Problem:

The issue I am facing here is that this even get fired only when a new mail comes in "Inbox" folder under "Outlook Data File". But I used to receive mails in the other "Inbox" folder marked by second red arrow (third last folder)

Due to this problem My Item_Add() event is not being triggered & resulting to my outlook macro Fail.

Please do help if you have some valuable inputs.

1 Answer 1

3

It sounds like you only initialized the handler for the Inbox DefaultFolder (olFolderInbox). You also must add a handler to the Inbox folder for [email protected].

2
  • Any idea how to set handler for the gmail inbox folder ? May 11, 2014 at 20:19
  • 1
    So you can get a reference to the folder with the following: Dim f As Folder Set f = Application.Session.Folders.Item(" [email protected]").Folders.Item("Inbox") If you declare: Public WithEvents Inbox2Items as Outlook.Items you can then set Inbox2Items: Set Inbox2Items = f.Items And you can then catch events: 'code' Private Sub Inbox2Items_ItemAdd(ByVal Item As Object) ... End Sub 'code'
    – cburn11
    May 13, 2014 at 3:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.