The Microsoft Dynamics CRM Blog
News and views from the Microsoft Dynamics CRM Team

E-mail to Case/Lead Using CRM 4 Workflow

E-mail to Case/Lead Using CRM 4 Workflow

  • Comments 53

A frequently asked question is about converting an incoming email into a case (or a lead). If you open an email activity, it has actions to convert it into a case or a lead or opportunity. More commonly, there is a need to automate this process.

In this blog, I’ll give a walkthrough’ of how you can use CRM 4.0’s workflow capabilities to automatically convert emails into cases. Say you want to automatically create a case for every email sent to: support@mycompany.com

At a high level, you need to:

1) Create a queue and map it to the email address at which email messages will be received (support@mycompany.com in this example)

2) Configure the queue to automatically create email activities for incoming email.

3) Create a workflow rule on email activity create. This workflow rule will be defined to create a case based on the email activity being created.

Create/Configure a Queue

You can create a queue by going to Settings -> Business Management -> Queues. For email integration to work with Queues, it is important that email integration be setup correctly. http://blogs.msdn.com/crm/archive/2008/02/07/crm-4-0-e-mail-integration-overview.aspx has a good overview of how to do this.

In my example, I’ve named the queue ‘MyCompany Support Issues’ and configured it to automatically create email activities for all emails received at support@mycompany.com

clip_image002

Define Workflow Rule

For this blog, I want to use only the workflow UI to define the workflow rule and avoid having to use custom workflow assemblies. Here is an outline of the logic we want to execute in the workflow:

When an email activity is created

{

If the email is sent to: ‘support@mycompany.com’ then

{

Create a case. Set fields on the case based on the fields of the email activity.

Update the email activity – set the email activity as regarding the case that was created above.

}

}

Here is how to do this thru’ the workflow UI editor:

1. From settings -> Workflow, select create a new blank workflow and select the Entity as E-mail

clip_image004

2. Configure properties of the workflow – I’ve set the scope to be organization and made it available for on-demand execution. If the workflow is marked as available to run on-demand, On-demand execution makes it easy for me to test the workflow

3. Add a check condition step and configure the step. This step will check if the email was sent to the support queue.

a. Select Email from the first drop-down list.

b. The 2nd drop-down now lists all the fields available on the Email activity. You can select the To field or the To Recipients field. The To Recipients field is useful if the email is sent to multiple recipients.

c. Select the Equals operator for the 3rd drop-down

d. To set the value that the To field should equal, click on the lookup, select ‘Queue’ for the Look For drop-down and search. You should find the queue that you created.

 clip_image006

e. If you decided to use the To Recipients field, simply type in the email address as shown below.

f. Save and Close the condition.

clip_image008

4. Add a create record step if the above condition is true and configure it. This step will create a case and properties of the case will be set based on the incoming email.

a. Select ‘Case’ as the entity to be created and use the ‘Set Properties’ button to configure how the case should be created.

b. For the case title, I used the workflow editor’s ‘Dynamic Values’ capability to set the title of the case to be the same as that of the incoming email activity’s subject. The online help for the workflow page has more details on how to use dynamic values.

c. Creating a case requires at least a customer and a subject to be specified. If the email is from someone who isn’t already in the system, you might want to have the workflow rule create a contact for the sender. To keep the example simple, I’ve opted to use a default contact (a contact named Test) if the sender is not recognized.

d. Save and close the create case step.

clip_image010

5. To link the email activity to the case created, add an update step on Email entity. Update the email’s regarding field to be the case that was created in the previous step.

a. On the form assistant, select ‘Create Case (Case)’ for the LookFor drop-down. The next drop down will now show the fields on the case record that are available (such as the case itself, or the customer with which the case is associated etc). Select ‘case’ for the second drop down, hit the ‘Add’ button and ‘ok’ to finish the association.

clip_image012

6. Hit the ‘Publish’ button to publish the workflow.

clip_image014

7. Test the workflow by creating an email activity. Set the To field on the email to be the queue. You should find that a case has been created for the email and the email activity is now regarding the case that has been created as shown below.

clip_image016

The above workflow is an example of a simple email to case conversion. If you have more complex conversion requirements, you might find that you might need to write a custom workflow assembly to implement your requirements.

Jagan Peri

  • PingBack from http://www.biosensorab.org/2008/02/19/e-mail-to-caselead-using-crm-4-workflow/

  • Great post, the only missing part is removing the email from the Queue as it has now been 'processed'.  Is there a way to do that?

  • I tried this but am not getting the expected results.  Emails that arrive in my queue have the from address set to the correct CRM contact and the regarding as blank.  The case get's created correctly but the case customer can only be linked to the email regarding which is blank and therefore uses by default value not the from address of the email.  Did I miss something?

    Thanks.

    Shaun

  • I have the same problem as Shaun,

    The email that is dropped in the queue does not have the regarding field set to the account so I can't assign the case to the account.

    Any suggestion?

  • Having an issue as well.  Am I right in stating...this workflow will fire with each email created, regardless if related to queues or not, because the "start when" is marked as "record is created"?  I think I got into a nasty loop.  So my other workflows that send auto response emails are getting mixed up...leaving workflows in "waiting".

  • Eric: Yes, the workflow applies to all emails and not just the ones from within the queue created.

    I had the same surprise when I tried to implement it. I wish there was a way to limit to the queue only because it seems like a lot of resources are wasted trying to apply the workflow on all incoming emails when only 10% are actually worth testing (and we know which 10% it is!).

  • Have you figured out how to assign the case to an account?

    I have the same problem when trying to convert an e-mail to campaign response.

    You save my day if you have a solution! :-)

  • Have a look at

    http://www.codeplex.com/crmqueuemanager

    as well. Solves some of the problems, but isn't as intuitive as a workflow.

  • I have the workflow working well.  My big issue is trying to get the text equivalent of the message body into an ntext field in the case.  The email attribute {Description} moves across as HTML text.  The email attribute called {Email Message} has only part of the actual text?  How do you get the body of the email in pure text for use in a text field?

  • I apologize for the delay in responding to the questions. I would like to address the questions around the regarding field not being set on the email activities.

    There isn't an out-of-box solution that will automatically set the regarding field of  NEW emails to point to a customer. There are workarounds available. To understand the limitation, let us walk through how email smart matching works. http://blogs.msdn.com/crm/archive/2008/01/29/what-s-new-in-microsoft-dynamics-crm-4-0-e-mail-integration.aspx has more details...

    When a new email is received, the email router creates an email activity and can populate fields on this email activity. It can fill in from/to fields. For regarding fields, it tries to check if there are any existing emails with similar subjects/participants and if there is a match, it will set the regarding of the newly created email activity to be the same as that of the match...

    What happens if there isnt an existing match? Now, emails can be regarding not just accounts/contacts -- They can be regarding a fairly large number of entities in the system (quotes,orders,invoices etc) including custom entities... Hence, the email router leaves the regarding field blank since it doesn’t have an easy way to guess what this email is about...

    As a workaround, you can write a custom workflow activity (or a plugin) -- For example: If you enforce that all submissions to the support queue have to include a customer identifier (could be an email address or some other identifier), your plugin/custom workflow activity can retrieve the account/contact that matches this identifier and set it as the regarding object (be sure to set the regarding value only if it hasnt already been set by the router).

    I'll be happy to post the sample code for doing this if there is enough interest.

    thanks

    Jagan Peri

  • I'd be interested in the sample code.

    Thanks,

    Wilson

  • In step 4c ..if the email is from someone who isn’t already in the system...

    How do I create a workflow to create a contact automtically?

    Regards,

    Hitesh

  • Voodoo Chile... Having implemented the workflow described by Jagan here to take an incoming e-mail and

  • I echo the question from JKDeveloper how to populate the case descrition from the e-mail description. We assume you either strip out the text portion of the e-mail or somehow use an iframe.

  • Am i missing sonething here, I am unable to get the case assigned to the person who sent in the email - am i th eonly one who got this wrong?

Page 1 of 4 (53 items) 1234
Leave a Comment
  • Please add 3 and 3 and type the answer here:
  • Post