latest Post

Automatically Sending Draft Emails in MS Dynamics

Recently I found myself wanting to send an email to a bunch of Dynamics CRM Users after doing some data processing from Dynamics in a custom application.

I decided rather than sending the email from the custom application the users would benefit from the email activity being visible within Dynamics for auditing purposes and to also leverage the email error handling already in Dynamics.

Now to achieve this I just created a new email in CRM using the Kingswaysoft CRM destination control in SSIS and  set the status to "Pending Send".

I was thinking this would create the email activity in CRM and then automatically send the email to the users however, I found what actually happened was the email was created in CRM but the email was stuck in "Pending Send".

If I set the email status to draft I could then open the email in CRM and manually hit the "Send" button but I am sure in the past simply setting an email status to pending send would send the email.

I then decided what I would do is create the email in draft then create a workflow which would fire on creation of the email and set the status to "Pending Send". However, again this failed to trigger the email to actually send.

Turns out this feature hasn't worked since CRM 2015 Release 1 it shows how long ago its been since I needed to trigger the sending of an already created email which makes sense as usually you create the email in CRM and send manually or for automated email you create the email from scratch within the workflow.

Anyway to trigger the email automatically from CRM I had to create a custom workflow which fires when a new email is created with a particular subject line which I have blanked out and status reason equals draft. I then make a call to a custom workflow which triggers the sending of the email.



The custom workflow simply calls the following code block to send the email using the SendEmailRequest() SDK method.

Once the custom workflow ran the draft email was successfully sent out. The following two blog posts helped resolve this issue: 

https://crmtipoftheday.com/601/reliably-send-email-in-workflow/
https://trellispoint.wordpress.com/2017/07/28/setting-email-to-pending-send-doesnt-work-dynamics-365/



Recommended Posts × +

0 comments:

Post a Comment