I am using a Application_NewMailEx
to treat all emails received.
It works fine on emails received while Outlook is open.
However on startup, the Application_NewMailEx
does not get called by received emails.
I tried using a Application_Startup
but it is called before emails are received ==> does not work.
There is no application.ontime to delay the startup macro...
Application_NewMail
does the same.
How can it be done?
Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
INIT_FOLD
TreatMsg Application.GetNamespace("MAPI").GetItemFromID(EntryIDCollection)
End Sub
NewMailEx event will fire only for the messages received while your code was running. It will not fire for the emails received in your (Exchange?) mailbox before that.
You can either process the unread emails in the Inbox on startup (
Items.Restrict
orItems.Find/FindNext
) assuming that new unprocessed messages are still unread or (in case of cached mode) useItems.ItemAdd
event on the Inbox folder - it will fire when your OST file is being synchronized with the remote mailbox.