E-mail to Case/Lead Using CRM 4 Workflow

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


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


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.


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.


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.


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.


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


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.


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

Comments (53)

  1. Travis says:

    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?

  2. Shaun says:

    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?



  3. Tony says:

    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?

  4. Eric says:

    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".

  5. Tony says:

    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!).

  6. 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! 🙂

  7. DaveMi says:

    Have a look at


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

  8. JKDeveloper says:

    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?

  9. jagan_peri says:

    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.


    Jagan Peri

  10. Wilson says:

    I’d be interested in the sample code.



  11. Hitesh Varsani says:

    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?



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

  13. 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.

  14. Gavin says:

    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?

  15. Enrique says:

    I have same question about the description in html format as JKDeveloper and Cencom. Case is created but the contents in description field is not legible. Any hint?


  16. Solodev says:

    I am doing this workflow, but also then creating a task for the case.  I would like the body of the email inserted into the task.

    I saw someone above ask something like this.  Is it possible to insert the email body anywhere using the workflow tool?

    Thank you in advance,


  17. jagan_peri says:

    Hi Shawn,

    The description field on email has the body, so you can use that to insert the email body into the task that you are creating…

    The issue that was brought up is that the email description field has additional tags dealing with fonts etc (<P><FONT face="Tahoma, Verdana, Arial" size=2> as an example). There isnt any field on email that has just the plain body without the above tags…

    Just an idea as I’ve not tried this — One workaround might be to have some jscript code that can filter out the above tags when a task is being loaded..

    Jagan Peri

  18. Jamie says:

    In my workflow, on the step which creates the case, I have the "Customer*" field set to "{Regarding(E-mail)}". As per your tutorial. However, no matter whic customer sends an email, the case is never created due to an error: "The Incident is missing parent customer".

    Which means that it could not find a contact with the email address from which the original email was sent.

    I know that that contact is valid with the correct email, and there is no duplicates and the email when it arrives in the queue resolves it to the correct CRM contact as well…

    Jagan, if you specify NOT to choose a default contact (in your case, "Test"), does your case creation resolve properly to a real CRM contact?

  19. jagan_peri says:

    Hello Jamie,

      I’m suspecting that in your case, the email activities have their regarding set to some thing other than a contact (for example: the regarding could be another email etc)… This is actually the default behavior of the email router.

      Can you open your email activity and check its regarding property?

    You might also want to check out a more recent blog from me on how to make emails resolve to the correct contact — Search for "Custom Workflow Activity for matching email addresses to customers"



  20. Jamie says:

    When the email comes into the queue, the regarding field is empty… I have tried many different queues but they all come in with the regarding field not being set. Is there something I must do when setting up the queue to ensure that the Email regarding field gets a Contact put into it?

  21. jagan_peri says:

    Hi Jamie,

      You can look at a response that I posted for this blog (on Tuesday May 13) explaining why the regarding field shows up empty…

      One way to workaround this is to write a custom activity that sets the regarding field based on sender’s email address — You can search for a blog "Custom Workflow Activity for matching email addresses to customers" to see the sample code.


    Jagan Peri

  22. Peter P says:

    I am trying to create an Email to Lead with no luck – so I tried an Email to Case and I don’t even get the Queue populated. Followed every step to the letter – Just doesn’t work.

  23. Engan says:


    Your article is very useful, but i have a problem: The original email still is in the queue. Both the new case and the email.

    Is there a way to remove it automatically?


  24. Chris says:

    Hello Jagan,

    I have been reading these posts and I have a problem similar to those described above – I need to to know how to have a workflow in CRM 4 create a contact automatically.  Could you send me the code you mentioned in the post above from Hitesh Varsani?  



  25. Vishy says:

    I have slightly different problem,

    When a case record is assigned to a queue, an E Mail has to be sent , how can i acheive this, i tried workflows which dint work please kindly help me on this…

  26. I am attempting the reverse of what you have mentioned here, i.e., I am dealing with output properties.

    Imagine receiving an email and I need to check something upon receipt before I proceed.  Such as does this email represent a case/incident/customer that already exists.

    So I created a custom step with a CrmOutput property that returns 0 if this is an exsiting case and a 1 if a new case needs to be created.

    My worklfow looks like:

    if custom step is 1 then

     create new case

     exit workflow

    My problem is that when I create a check condtion I see no signs of my output property.  So how do I create a condition for it.  What am I missing?  Shouldn’t my output property be visible somewhere in the UI for a check condition?



  27. Nevermind.  I deleted my workflow from the UI and recreated it using my custom step and now I see my output property in the check conditions.



  28. Hi All

    This is reagrding free addon which is available at our site, Which  has following features:

    This is an addon to outlook


    I have tested this product out and owrks great.

  29. Rohit says:

    Please tell me procedure to do it using .Net.

    As i am new to customizations.

  30. How do we do this for internal users?  AKA a support queue?  I can’t find a wa to set the regarding to be a user.

  31. Dominic Snell says:

    We have implemented a workflow that also has a custom function that populates the regarding field of the email before creating a new case. This works fine. For anyone else doing this work – make sure your workflow also checks the Email Tracking token for new emails recieved. This way, a new case will not be created for emails that are in reposnse to CRM emails.

  32. Joeri says:


    this is a very interesting thread.

    In our company i would like to do the following scenario :

    I have a Queue setup where all requests come in from customers.

    We have a central person looking at the Queue and deciding for who this message is intended.

    this person makes a selection thru a custom item on the mailform.

    the persons who the mail will be intended to are non CRM users.

    Once the selection is made, a case will be created automatically. (all this is working well with workflows.

    What i want now, is a way to forward the mail coming from the customer with a tracking token to the created case… as the original mail got into the history of the created case…

    since the other people are non crm users they got nothing of course.

    any way i can auto forward a mail by using a workflow ?



  33. Simon says:

    I got around the issue of having the case and email in the same queue by creating a new queue (called ‘Email Archive’) and asigning the email to this queue in the main workflow.

    Works for us, is easy for the user to look at incoming emails, and (eventually)I’ll write a system job to purge the emails in this queue automatically (say every 24 hours.)

    Happy Coding,


  34. Pal says:

    What happens when i mark 2 or more queues in to recipients of the email and send it to CRM? Will it create many tickets? How does this work in CRM?

  35. jasper says:

    We’re using a workflow very similar to this workflow to handle our incoming support requests. However we have not been able yet to solve the issue of all the email activities in the queue.

    It would have been nice if this how-to followed through, and suggested how to deal with the emails in the workflow.

    Otherwise this how-to does not seem complete in my point of view.

  36. I LOVE C# says:

    1. Microsoft VPC Software – Allows running a virtual machine, required for item 2 in this list http:

  37. Harish shinde says:

    I m facing deployment issue while working with Custom workflows.. is there is any steps I need to follow..I deployed the dll using plugin registration tool and also publish my workflow..but some time it doesn’t work and when I do the iis reset or re publish the workflow it will start working.. does anyone identified the same issue what is the resolution..

  38. Bill says:


    I have followed the above instructions to creat a case using workflow,

    i have created a queue cc-support, all support emails comes to this queue.

    when i receive the email the workflow runs …and i check the workflow status it says succeeded, but they case is not generated. i cant see any case being generated under cases.

    can any one replay please.. thanks in advance.


  39. Bill says:

    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 .The case doesnt get created, but wen i check the system job the status reason is succeeded.

    any Idea?

  40. TonyV says:

    I have the workflow running, but when the e-mail regarding is updated the Body of the e-mail is removed, so we loose the incoming e-mail question.

    I’ve tried re-inserting the Description, but this adds formatting tags as mentioned above.

    The only field I have touched in the Update is Regarding.

    Is there something I am doing wrong for the e-mail body to be stripped out in the frist place?

    Suggestoins? Thanks,

  41. Vasiliy Bulgakov says:

    Good blog, help me with creation of "email to case" 🙂

    But I have one question – if I have custom fields inside case – how I can fill it from email?

  42. Dmitry says:

    A work around on how to set the regarding field.

    1) Create a Hidden txt box on the Case

    2) Set the Hidden txt box with the FROM field in your workflow when creating the Case

    3) Create a JavaScript call to query they DB for a GUID that corresponds to the Name on the on Load of the Case

    4) After the Lookup is set on the first onload of the record clear out the Field and put a check at the start of your javascript to check if not Null

  43. Casper S. says:

    Hi Dmitry

    Is it possible for you to tell me abit moe about your solution. You loose me at number 3 and 4

  44. Joe says:

    I have all of this working – thanks for all that have posted.

    Big problem is that using {Description(Email)} to include the original email body results in lots of formatting tags being included and any original embedded pictures (screen shots, etc) are lost.

    Can the original email body be included correctly or can the original email be forwarded as an attachment?


  45. Timo K. says:


    Have a look at


    Paste this Javascript-Code in your OnLoad-Script.

    It works fine for me.

  46. Kenneth says:

    I’m trying to use a plugin assemblies but i can’t get it triggered on an email arriving in the queue. Anyone knows which entity i should put in the plugin registration tool?


  47. JanetteSmith says:

    I am having major issues getting the account and contact field to populate.  When my email converts to a case these fields are blank.

    Please Help!

  48. Charlie says:

    Please help… I have a web form that is generating the sales email to be converted to a Lead. I have everything working – BUT… How do I get the company field on my web form to match to the company field in the Lead?

    I am not a developer and have got this far due to your excellent instructions… however it must be possible to get the Company field populated… after all this is a business solution.?

    Thanks in advance…

    (me pulling my hair out…)


  49. Danny_Archer says:

    when i am using regarding dynamic values in the fields the workflow doesn't run, when i remove them and put simple text values it works just fine. What is the reason and solution to this problem?

  50. Danny_Archer says:

    the customer 'Test' in this workflow is hardcoded here and it's not dynamics as such, what if a customer other than 'Test' sends email?? this workflow won't work for that, so when different customers send emails then how to use dynamics values here to make this workflow work?

  51. Greg says:

    Will this workflow solution work for CRM 2011?

    if not is anyone aware of a posted solution for 2011?

    Thank you,

  52. moh10ly says:

    Hi Greg,

    In my case it works, but when testing only with send e-mail as mentioned in the steps in the tutorial, however if the e-mail is sent from any customer it will not work.

    This happens coz I haven't specified the customer yet. I need to put everyone in there.

    It works well and pretty easy.

    Thanks to Jagan peri.

Skip to main content