Steps to Send Emails to Custom Email Address Text Field from a Workflow

Steps to Send Emails to Custom Email Address Text Field from a Workflow

Written By: Chad Rexin

from March 13, 2015

Recently we had a customer who had customized the Incident entity and had added a custom text field to the entity that was used to store an email address.  This data was being brought into Microsoft CRM incidents via an integration with a website portal that the customer was using and they were unable to use a workflow to send an email to an email address populating in a custom field.


The problem they had was that they wished to use a workflow to send an email to the email address in this custom text field.  Microsoft CRM Incident is not an email enabled entity and the workflows are only able to send email to a primary email address from an email enabled address.  This means that if the email address had been added to the Account Email or Contact email fields, that this could have been used in the Incident entity workflows to add to the To field.  However, for this deployment, it didn’t work to simply map to an existing account or contact, since the data may have been different coming in from the portal.

I’ve seen various posts on the Internet and community solution pages indicating that sending an email to an email address in a custom text field was not possible and that if it was wanted, that a custom workflow action/plugin would have to be developed.

After working on this, I realized that in Microsoft Dynamics CRM 2013 and Microsoft Dynamics CRM 2015, it’s no longer a necessity to have custom code in order to allow workflows to send email to an email address from a custom text field.  Below I’ll provide the steps I used to get this to work, noting that in summary, all that is necessary is a Custom entity that is email enabled in order to populate with the email address via a RealTime workflow.  This can be applied for any entity where a customer wishes to use a workflow to send emails to an email address not included in the primary email address for the entity (or if the entity is not email enabled).

*** Note that this solution does not perform any email address validation, so if that is needed, you would still need to have some custom development performed do do that or else ensure the addresses are validated before they are integrated or typed into Microsoft Dynamics CRM records.

Steps to send emails to custom email address text field from a workflow.

1. Identify which field contains the email addresses on the entity you wish to send emails to via workflows. (in this example, the field used is sgs_primaryemail and is on the Incidenty entity (renamed to Request))

2. Create a custom email enabled entity to store the email address into.

1. Create an entity named “Incident Email” and make sure to mark the  checkbox for “Sending email (If an email field does not exist, one will be created).  Mark the Area that you wish to see this in for initially setting this up and validating that everything works (this can be unmarked after it is setup since you won’t need to see this entity in the application as it can simply be referenced by the workflow).

2. From the Incident entity, create an Incident Email Lookup field that is linked to the Target Record Type of “Incident Email” and add it to the Incident form (you can make this field hidden if you wish by unchecking the “Visible by default” of this control since it’s going to be populated via a real-time workflow).

3. Create a Process (Microsoft CRM Workflow unchecking the option for run in the background) and name it “Populate Email Address for Incident Email”, selecting Incident as the entity.  For testing, mark the check box “As an on-demand process”, and Have the scope of Organization, Start when set to “After” and mark the checkbox for “Record is created”  Mark the option to Execute as “The user who made changes to the record”.

1.  Set the workflow steps to “If Incident Email:Name contains data, then: Create – Incident Email setting the following fields:

a. {ContactName1(Request)}

b. Email Address {Email(Request)}

2. Create a new workflow step to Update Incident with the set properties to: Select the Incident Email Lookup field and add the local value, {Incident Email (Create Incident Email entity email record (Incident Email))}, which comes from the Local Values in the “Look For:” Form assistant.

3. Save and activate the real time workflow.

4. Now that this is done, we can create our workflow for the Incident entity to send an email to the email address that is in the custom field.

1. This should be created for the Incident Entity and have a first step of “If Request:Primary Email contains data, then:”

2. The 2nd step should be Send email: Create New Message – Set Properties (at a minimum, the From needs to be an email like a CRM User with a valid email address and the To should be set to {Incident Email (Incident Email (Incident Email))}, which is just the way we can tell CRM to use the Email field from the Incident Email entity.  Fill in the Subject and Body with the appropriate text for this email to be sent via workflow.  Save and close the email properties.

3. This workflow to send email can be run in the background and should be triggered off of the Start When “Record is created”.

4. Now Save and activate this workflow.

5. To test everything is working properly, we need to go back to our Incident entity and to create a new record, which should populate the Incident Email entity with a new record, populate the lookup on the Incident Email, and send an email to the email address selected on the Incident for the custom primary email address field.

Screen Shots

Screen shots are included below of the process to complete the workflows described above.

Incident Email entity properties – note that it is marked for “Sending email”

Send Email Via Workflow1

Incident Email Lookup field on Incident Entity (named Request in this example)

Send Email Via Workflow2

Populate Email Address for Incident Email workflow properties

Send Email Via Workflow3

Create Incident Email entity email record properties

Send Email Via Workflow4

Update Incident Request to populate lookup properties

Send Email Via Workflow5Send Email Via Workflow6

SendIncidentEmailTest workflow properties

Send Email Via Workflow8

Email Message properties

Send Email Via Workflow9

Custom Contact fields on Incident with Incident Email lookup and Primary Email field.

Send Email Via Workflow10

Drilling in on the Incident Email Joel record

Send Email Via Workflow11

Additional Notes: This example just used a name field for the related entity, Incident Email, but could concatenate two or more fields together to add some uniqueness to the field. The other thing that could be done would be to create a duplicate detection rule to prevent duplicates for this entity.