Sending E-mails with Dynamics CRM Workflows


E-mail has come to be one of the most commonly used communications vehicles, and it’s certainly an activity many organizations use to communicate with customers. It’s hard to imagine a customer-relationship management system without integrated e-mail management, and Dynamics CRM has an excellent implementation in this area. Need to learn about workflows in Dynamics CRM? Consider my one-day live online class, Building Workflows in Dynamics CRM, which also includes a copy of my book on the topic.

Some of the most important aspects of E-mail integration within Dynamics CRM are:

  • The Outlook client makes “doing CRM” a simple extension of the Outlook experience, and as I’ve written elsewhere, if something’s easy enough to do, people will do more of it. When it comes to tracking an organization’s interactions with its customers, this is usually a good thing!
  • The E-Mail Router provides centralized management of E-Mail integration, such as the ability for a marketing manager to send out campaign e-mails on behalf of other Dynamics CRM users. And it integrates with any POP3 E-mail server. (And now it even works with BPOS!)
  • Third parties and ISVs can extend the core feature set with supported APIs and web services. For example, if you use Exact Target or Constant Contact to manage and track your e-mail marketing efforts, there are add-ons you can use to bolt those right into Dynamics CRM, relieving you from the tedious tasks of exporting from CRM, importing to your hosted e-mail and tracking results in two different places.

How do e-mails and workflows interact in Dynamics CRM? Here’s how I think about it:

  • Workflows can send e-mails.Send E-mail” is one of seven actions a Dynamics CRM workflow can perform, and it’s definitely one of the first activities many organizations attempt to automate with workflows.
  • E-mails can trigger workflows. In addition to being a very useful and commonly used method of communicating with people, E-mails are also customizable entities (in Dynamics CRM-speak). An implication of that is that a workflow can be triggered whenever a new e-mail record is created in Dynamics CRM. For sales or service organizations that want to respond appropriately when customers send certain kinds of e-mails, this gives you an important integration point!

In this article I will focus primarily on the first of these – sending e-mail messages from a Dynamics CRM workflow. I’ll give you some of the most common scenarios I encounter, plus some tips and tricks.  Before we dive in, it’s worth reviewing who can receive e-mails from Dynamics CRM. Whether sent manually or from a workflow, Dynamics CRM e-mails can be sent to:

  • A Dynamics CRM User
  • An Account, Contact or Lead record
  • A Dynamics CRM Queue

When to Send E-mails from Dynamics CRM Workflows?

In Dynamics CRM, just like in the real world, e-mails can be sent for any number of reasons. Here are three simple examples of how you might send manual e-mails:

  • You can send an e-mail from Outlook and (if you’ve got the Outlook client installed) click Track in CRM to have CRM create a record of it and attach it to a contact or account record.
  • A marketing manager might distribute an E-mail type campaign activity, and send hundreds of e-mail messages on behalf of the owners of contact records in a marketing list.
  • A sales rep might create an Advanced Find view of contact records, and click the Send Direct E-mail button at the top of the contact grid, as the following figure illustrates:

Those are all examples of manual e-mails. When and why would you send e-mails from workflows? Here are a few scenarios when sending e-mails from Dynamics CRM workflows is useful:

  • Auto-responders. An automatic workflow can run when a new lead record is created, sending an appropriate e-mail when a visitor to your web site fills in a “request information” form. I wrote an article about this, using as an example the auto-responders we send when somebody registers for a Dynamics CRM User Group meeting.
  • Event follow-up. If you have more than a few people attend an event, you can save time by using a workflow to automate the e-mail follow-up process. This is also a good example of where an “On Demand” workflow might be the best option, and I’ll show an example of this below.
  • Expiration reminders. Suppose your customers have subscriptions with expiration dates, or suppose they’re locked into a competitor’s contract and that has an expiration date. In cases like that, as the clock ticks you get closer and closer to a potential sales opportunity, and a workflow can send appropriate e-mails to your sales team and/or the potential customer.
  • Sales and service process notifications. Opportunities have the “Est. Close Date” field, cases have “Follow Up By”. If opportunities don’t get closed or cases don’t get resolved, a workflow can take appropriate action…including sending notification e-mails to various stakeholders.
  • Assignment notifications. Workflows can be triggered when the owner of any record type changes, so you could have an automatic workflow notify users they’ve been assigned a new lead, account, or any other kind of record.
  • Case-acknowledgement e-mails. We’ve probably all received these at one time or another. [One of my favorite examples was an automatic e-mail I got from Google after committing a mortal Adwords sin. It included the following text, "If you have any questions about your account or the actions we've taken, please do not reply to this email nor attempt to contact us in any way." If
    you're trying to generate fear and loathing this is an excellent approach; otherwise I recommend a more constructive case acknowledgment e-mail style.]

E-mails, E-mail Templates, and Entities

I mentioned above that Dynamics CRM e-mails can only be sent to five kinds of entities: users, customers (accounts and contacts), potential customers (leads), and queues. So, in order to send an e-mail to a customer regarding a case or an opportunity or another kind of record, how do you do it?

I’ll start with what you can do manually, through the Dynamics CRM UI, then I’ll show you the additional flexibility you get if you understand how to send e-mails with workflows.

Even though you can only send an e-mail to those five entity types, you can actually create e-mail templates for many kinds of records, as the following screenshot illustrates:

In addition to the five aforementioned, you can see nine additional ones: Global, Opportunity, Quote, Order, Invoice, Case, Contract, Service Activity and System Job. Although you cannot e-mail these records directly, each of these record types has a so-called “many to one” (“N:1″) relationship to one or more of the five record types that can receive e-mails.

Essentially, the Dynamics CRM design team gave us a shortcut to make it a little easier to send e-mails to contacts or user records, for example, which are related to commonly used records such as opportunities and cases. This is why, even though you can’t send an e-mail directly to a case or an opportunity, you do see the Send Direct E-mail button at the top of the Opportunity grid:

So, when it comes to these built-in (also referred to as “system”) record types, you can either use some of the built-in templates, or create your own custom templates to expose a simple direct e-mail function to users. It’s just that the e-mail doesn’t really get sent to the opportunity (everybody knows opportunities can’t read e-mails!)…it gets sent to the contact, or the owner, or the account, depending on how you create the template.

OK, so far so good, but what happens if you need to send an e-mail regarding something other than one of those built-in record types? For example, I use a custom entity (“Registration”) to record registrations at events (another custom entity). How well I remember my horror the first time I realized there was no Send Direct E-mail button at the top of the registration grid for an event:

The screenshot shows the “Associated View” of registrations – that is, registrations associated with the selected event. I’ve got the grid toolbar highlighted in yellow in the figure – that’s where you’d need the Send Direct E-mail button to be. It’s easy to get this confused, since there’s also the Send E-mail button I have highlighted in black. That’s lets you send an e-mail regarding the Event – not what I want to do here, which is to send a nice follow-up e-mail to every person who attended the event.

So how do you do it? Here are some options:

  • The first time you see this, you might try to create an e-mail template for “Registration”. But you cannot create e-mail templates for custom entities, so although that would be nice, we’ll need to wait for Dynamics CRM 5.0 for that.
  • You can actually create a mail merge template for custom entities, but working with mail merges can be a little kludgy. Plus, there’s no easy way to attach a file to an e-mail sent via mail merge, a limitation which can be solved if you use a workflow.
  • You could send e-mails out one at a time. I created a 1:N relationship from Contact to Registration (along with another 1:N from Event to Registration), so I can click on the contact name in the registration list, access the contact record, and e-mail away. But that takes too long.

The best way to accomplish this is with a workflow. Here’s how you do it:

  1. Create a workflow on the Registration entity. You could make this an automatic workflow but I like On Demand for this kind of workflow. Here’s what my workflow’s properties look like:

     

  2. This workflow has one action – you can see the Send e-mail action highlighted in yellow. I use Create New Message, although there’s also a Use Template option. Since I’ve got a 1:N relationship from Contact to Registration, I could use a contact e-mail template here. That would let me send an e-mail to the right contact, but…it would not let me attach a file to the e-mail! When I’m sending follow-up e-mails for my events I usually attach the slide deck, so I need to use the Create New Message action.
  3. Next I click the Set Properties button to configure the e-mail. The following figure shows how to configure the e-mail. The most important part is the To line. Notice I’ve got the Look for drop-down highlighted, and I’ve selected one of the Related Entities. In this case since I want to send the e-mail to the Contact, that’s the one I select: the workflow design environment knows there’s a 1:N from Contact to Registration, which is why this works!

  4. Finally, notice there’s a tab for Attachments, even in the workflow design environment. That’s what lets you do something like you see in the following figure:

     

That’s pretty much it. Once the workflow is published and I’m ready to send my follow-ups, all I need to do is open up the event form, click on Registrations, select them, and the Run Workflow button will be available. The following figure shows what it looks like after I click the Run Workflow button, just before I execute the workflow to send out the e-mails:

 

Summing Up

OK, that article was longer than I thought it was going to be, but I hope it was worth your time. I tend to write about things that initially confused me, partly because it forces me to remember what the solution was, and partly because I figure if they confused me, they may confuse somebody else. Here are the main two points to remember:

  1. Workflows can still only send e-mails to Users, Accounts, Contacts, Leads or Queues…but the workflow UI gives you a handle to related records, so as long as the thing you want to send an e-mail for has an N:1 relationship to one of the Big Five e-mailable entities, you’re in good shape.
  2. If you want to e-mail attachments, use the Send E-mail Message action, rather than Use Template.     

 
Here’s a link to my book, Building Workflows in Dynamics CRM 4.0. It’s available on Lulu and Amazon, and if you buy it you can use the $50 purchase price as a credit against the $200 registration for any of the CRM Training Essentials events I run on a monthly basis.

8 Comments »

  1. Steve Jacobs Said,

    February 19, 2010 @ 8:28 am

    IN the above post, you mention that the E-Mail router now works with BPOS.

    Are you referring to the CRM Online, or CRM On-Premise E-Mail router?

    The latest version of the on-premise E-Mail Router (that I could find) is dated 12/2007 and as of last Fall did NOT work with BPOS. Is there a newer version? DId one of the Update Rollups fix this?

    Thanks,
    Steve

  2. Richard Knudson Said,

    February 28, 2010 @ 5:30 pm

    Hi Steve,

    Sorry it took me a while to answer you, but yes I was referring to CRM Online. The currently downloadable version of the Dynamics CRM Online E-Mail Router supports the BPOS hosted version of Exchange. I’ve got it up and running myself and it works great.

    Better late than never, eh?

    Richard

  3. rachel Said,

    May 3, 2010 @ 7:48 am

    Hi Richard,

    I’m trying to set up a workflow to send an email to a queue. I’ve assigned myself as the owner and gave it my email address for testing purposes. The workflow shows that the process runs successfully but the queue contains no email. Is there a setting someplace else I need to adjust?

    We are on CRM 4.0 rollup 10

  4. SPS Said,

    May 26, 2011 @ 3:43 am

    Hi Richars,

    Is there any way I can send email using the workflow to users who got sharing on an Account, i.e whenever a user changes the status of an account I need to send email to the users who got sharing.

    Also is there a way I can send email when a user share an Account or can I trigger a workflow at the time of sharing an Account.

    I am bit new the MS CRM and it will be helpful if you can give some inputs on implemeting the above mentioned scenarios.

    Thanks

  5. Patricia Said,

    July 7, 2011 @ 10:23 pm

    Hi Richard
    Is it posible that attachment be personalised?
    We need to send a workflow email with an invoice as attchment and invoice needs to have recepient relevant information.

    Thanks for your help

  6. Richard Knudson Said,

    July 12, 2011 @ 6:42 am

    Hi Patricia,

    No, unfortunately you cannot do it the way you’d like to. Depending on your requirements, you might be able to accomplish your goals with a dialog process, since they can query CRM and present results to a user for selection (e.g., for a selected contact, present a list of invoices, and select one to e-mail to the contact)…but that’s interactive (requires user input), and it sounds like you want automatic.

    There’s not much you can’t do with a plug-in (e.g., when an invoice record is created, custom .NET code could e-mail a version of it to a customer)…but that’s custom .NET code and would be some work.

    If I come across anything easier I’ll write it up. That would be a nice feature!

  7. Brock Said,

    December 9, 2011 @ 1:45 pm

    Everything appears to be working, but when the workflow/process creates the email, it just sits in status “Pending Send”.

    I’ve verified inbound/outbound profiles in Email Router are configured and working when manually creating emails.

    What now?

  8. Brock Said,

    December 9, 2011 @ 1:49 pm

    Figures as soon as I post that I realize I had the step as “Create Email” instead of “Send Email”.

    Voila!

Leave a Comment