tisdag 30 augusti 2016

Send email from workflow gives User does not have send-as privilege error

Yes, I know, it's been a while but this is at least something new here.
I've been fiddling with email sending from workflow this week and when I was done, or at least thought I was done, and handed it over to testing I was slightly confused when all emails created ended up in status of Draft.

I had no idea what was going on. I started by looking at the trace logs of the server and found this

Process:CrmAsyncService |Organization:673c5996-a1fa-e311-93ed-00155d0a831d |Thread:   14 |Category: Exception |User: f1b2fe83-133c-47ab-8bc7-081c14c88fea |Level: Error |ReqId: bd557cc3-49d1-4fea-97c8-be0b1ada06f7 | CrmException..ctor  ilOffset = 0x7

Yes, that is very informative don't you think. The thing is it works when I do it but when my colleague, and in this case Boss, tries to do the same procedure nothing happens after the email is created.
The user in this case is the user SYSTEM which makes it even more confusing.

I finally found this thread: https://community.dynamics.com/crm/f/117/t/90680 in which it says to enable “Allow other Microsoft Dynamics CRM users to send e-mail on your behalf" in the settings. The file part here is the cog which opens the menu with the personal settings. This has to be enabled for the user that owns the workflow.

It turns out that this is not the solution, but rather a coincident that it actually works. When you have a workflow creating emails for you you will need to turn on the "allow other Microsoft Dynamics CRM users to sen e-mail on your behalf" for every user that will use the workflow. Probably because the workflow is run by a service account in CRM, but I really can't say.

Good luck out there!

Rickard Norström
Developer at CRM-Konsulterna