An Unknown Error Occurred sending mail in Dynamics GP with Office 365
Attempting to send email from Dynamics GP using multi factor authentication (MFA) results in an error, after selecting a user in the Office authentication window.
An Unknown Error Occurred
There is no explanation as to what the error actually was. In the case I was investigating some users could email and yet others could not. This is strange when the machines that they were using originate from the same base image.
After logging is turned on, it turns out the error underneath is that the following file does not exist:
c:\Users\{userID}\AppData\Roaming\Microsoft Business Solutions\Microsoft Dynamics GP\Microsoft.Dynamics.GP.BusinessIntelligence.TemplateProcessing.dll.msalcache.bin3
GP looks to be using the Microsoft Authentication Library (MSAL) to cache the Azure authentication tokens for the connection to Office 365 into this folder and file. However, if the folder does not exist then the library can not write the cache file . I looks like this folder will only be created if the user in GP has had the field auto complete feature in GP turned on, or has had it in use at some point in the past.
Details of Auto complete functionality is found here: Using AutoComplete functionality with Microsoft Dynamics GP
This feature also uses this folder to store the database files that drive the auto complete functionality.
It is controlled from the User Preference window.
Comparing a user that can send email against one that can’t using SQL
We can see one has auto complete on the other has it off and also checking the existence of the folder shows that the user encountering the error does not have the folder.
So after creating the following folder,
c:\Users\{userID}\AppData\Roaming\Microsoft Business Solutions\Microsoft Dynamics GP\
...it was found that email functionality will work correctly. I assume the developer of the email feature, assumed that this folder will always exists on all systems. They were unaware it may not be created if autocomplete is turned off. My guess is that code will not create the folder when it does not exist and hence the error.
Long term solution:
Creation of this directory has been added into group policy for GP users.
Hope this helps someone else, comment if you found it helpful.