System Email Accounts : The mail receive has failed.Exception has been thrown by the target of an invocation.

Userlevel 2

I’m working through the setup of System Accounts in anticipation of leveraging the Incoming Mail Processing feature.


I’ve encountered a few different issues over the course of setting up ~20 System Email Accounts that are connecting to our MS365/Azure tenant. For the most part, things are working as expected BUT there are a handful of accounts that continue to be problematic…


During the automated processing of the emails, some accounts encounter the error “The mail receive has failed. Exception has been thrown by the target of an invocation.” during the automated processing of the emails.


As suggested by other threads within this community, I’ve opted to recreate the System Email Accounts and it’s associated External Application from scratch. This did seem to work, initially, but roughly an hour later the problem resurfaced.


It’s been suggested that the error could be due, in part, to the quantity of emails being processed, specifically those stored within the defined root folder of the user’s mailbox. I’ve reviewed the storage volume and email count of all users and have not been able to find a pattern or threshold that makes sense. I suspect that the expression of this idea may have been over simplified, not sure.


Might anyone have insights into this?


Thanks a bundle ;-)


Best answer by DavidEichner 20 January 2023, 16:55

View original

10 replies

Userlevel 7
Badge +10

It might be a MS365/Azure tenant issue.  I have not had any issues with AWS tenant and Office 365 accounts.

Userlevel 2

@DavidEichner hrmm… I won’t deny that though all of the OAuth2 authentication is working without issue. I’d love to find out if there are any practical limitations within the system, max number of emails in defined root folder of the account or maybe the max number of emails in CRSMEmail per account and such.


Might I ask what your record counts are like? I have some users who keep their inbox very clean, in the double digits, while other have over 100k.



Userlevel 7
Badge +10

My old firm used email accounts for sending out mass email campaigns daily with 25K emails outgoing.  Those emails had images that made the database grow, but we never encountered any issues sending the emails.

Userlevel 4
Badge +1


Hope all is well today, I do have a suggestion for downloading/sending many emails at once.

Most email providers maintain limits for both send and receive (consider this “spam” protection).

Because of this, if too many messages are sent/received in a single minute, then the Email Provider may block any further messages from sending out for a while. 


To combat this, Acumatica offers a function on the system EmailAccount screen called “Group mails” 
What this does is, each time the system (or a human) selects an email account to receive/send, it will limit the # of emails that are sent in that single execution.

For example:
Let’s say my Email Provider has send/receive limits for every minute, up to 100 messages a minute
I configure my automation schedule to automatically trigger Sending/Receiving emails every minute (this is just as an example) 
If I place the # 100 into the “group Mails” box on the system email account, then every time the schedule executes, it will only move 100 messages during that 1 execution.

Here is an image showing the “group mails” option on a system email account record within Acumatica 



Userlevel 7
Badge +10

Hi @Missy Main 

Thanks for this info. I can see how this would help with some email providers.

Unfortunately, Office 365 also looks at other parameters as well like the number of emails sent in an hour, the number of emails sent in a day, etc. and then disables the account due to suspected hijacking of the account.  


David Eichner, CPA

Userlevel 3

Hi All, 

We are having a similar issue with one of the Email Accounts, we have 5 Email Accounts configured but only one of the Email Account is throwing exception “Exception has been thrown by the target of an invocation”, we have tried setting the limit under Group Mails to 10, but still the emails are still not getting downloaded. We are using basic auth for our on prem incoming mail server. Any thoughts how can it be resolved? Only option we see is reconfiguration, but not sure if the issue might pop up again.

Userlevel 3

As trial and error we changed the Root folder to some other folder name and can see emails are getting synchronized , but only a single email is getting synched at a time during automated schedule.

Userlevel 3

I’m experiencing same issue with ‘receive’ on only 1 email account.  Everything was running fine then during a ‘receive’ we started getting this error and can’t get past it.  I see a couple ‘maybe’ solutions above but no definitive resolution or root cause.  @davideichner seemed to think the Group Mail setting wouldn’t be enough in an Azure/365 environment (which this company is).  I tried a ‘Group Mails’ setting but no luck as @vibindas also replied .  Anyone else have any ideas? 

Is this error message being generated by Acumatica or something 365 is returning when Acumatica tries to grab the new emails?  We ‘receive’ every 5 minutes and after the last successful ‘receive’ there was15-20 emails sent to the mailbox on 365 so maybe there is something to the message count and 365 disabling something - but what?


Just curious if anyone else had any luck resolving this issue or other troubleshooting steps.

Userlevel 3

@kyoung14 as a temporary workaround we recreated the profile for the email account having the issue. We couldn’t find the root cause for the issue.

Userlevel 3

@vibindas - thanks for your response.  In our case it just started to work again after X hours.  Maybe Office 365 suspected the account had been compromised and locked it down from accepting requests from systems like Acumatica?  The IT team that supports this clients Office 365 couldn’t find anything to support that so I guess we just hope whatever it was that triggered this - doesn’t happen again?


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved