0
votes

I got an issue with the macro I did in Outlook. To resume, the macro starts every time I receive an email. Then it will run a few others Sub, modify an Excel file and so one. When Outlook is running and I receive a new email, everything works perfectly. The problem occurs when I open Outlook and I receive more than one email at the same time.

I suppose the macro doesn't have enough time to end what it's doing with the first email and already try to start again with the next one.

Is there a way to keep the next emails in suspend in order to run the macro for each email, each one has its turn ? Or maybe you have another solution ?

Thank you.

PS: I can provide the code but it's very long.

1
Did you debug to see where it crashes ? Is it always the same line ? Can you post where it crashes - Seb
I think we need to see the code and get more information about the "problem" (does it error out, does it just stop, what doesn't work as expected). - James SMith
Read MCVE. - Rdster
It is preferable to post very short, minimal code examples. However, at this point it would be helpful to see whatever code you have, to help understand what question you are trying to ask. To post long code examples, put them on an external site like pastebin or github and include a link in your question. - David Jeske
Yes please post the long code/Complete code- - 0m3r

1 Answers

0
votes

The problem occurs when I open Outlook and I receive more than one email at the same time.

The NewMailEx event of the Application class is fired once for every received item that is processed by Microsoft Outlook. The item can be one of several different item types, for example, MailItem, MeetingItem, or SharingItem. The EntryIDsCollection string contains the Entry ID that corresponds to that item.

The NewMailEx event fires when a new message arrives in the Inbox and before client rule processing occurs. You can use the Entry ID returned in the EntryIDCollection array to call the NameSpace.GetItemFromID method and process the item.

Make sure VBA macros are enabled and allowed to run when Outlook is started. Check out the Trust Center settings in Outlook.