none
New Mail skipping NewMailEx function RRS feed

  • Question

  • I have some code written in Application_NewMailEx to do different things with messages or nothing at all. One particular message that I need to direct as it comes in each time elusively circumvents that function. I put a breakmark right at the beginning of the function, but even before the VBA module opens up, I can see the item appear in the inbox. I am absolutely clueless how this is happening and hope somebody here can shed some light on it for me.

    Thank you

     
    Saturday, April 4, 2020 10:21 AM

All replies

  • Keep in mind that NewMailEx only fires for the messages that are actually *received* when your code running. If your start Outlook and it then syncs the messages received prior to Outlook startup, NewMailEx will not fire.

    In case of cached mode, use Items.ItemAdd event on the Inbox folder - it will fire events as it synchronized teh cached folder with the server.

    If you are using online mode, it is a good idea to use Items.Item.Find/FindNext or Items.Restrict to search for the unread messages on startup.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Saturday, April 4, 2020 8:07 PM
  • Outlook runs all day. I dont rely on synching. It's quite possible that something slips by whenever i restart. However, that isnt the cause of the issue at hand. I literally foward myself the item with a break at the start. Now that I am typing I wonder if forwarding is the reason. I will test this by sending it from another computer or maybe you know the answer. Do forwarded messages skip over NewMailEx and would the Items_ItemAdd function catch them? Well I only forward for troubleshooting anyway so no contingency needed. Isnt it good practice to enable Items_ItemAdd and simply call NewMailEx? There is nothing different that I would want done. Maybe i wont have access to the EntryID variable that goes into the latter. I will have to check this out

    Thanks for potentially helping me sound out a solution and for suggesting Items_ItemAdd

    Monday, April 6, 2020 5:08 AM
  • If a message is really sent (and not just created in the Inbox folder), NewMailEx event would fire as long as Outlook is running.

    Can you see NewMailEx event firing in OutlookSpy (click Application button on the OutlookSpy ribbon, go to the Events tab, look at the log at the bottom of the window)?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Monday, April 6, 2020 5:24 AM