This project is read-only.

Easy Plugin for Email to Case Creation

Jun 5, 2013 at 6:09 AM
First off, thank you for this tool it is very helpful.
I've built a plugin to create inbound emails into cases. What I'm struggling with is how to restrict the plugin to only create cases for 1 system user.

Thank you
Jun 6, 2013 at 10:52 AM
Edited Jun 6, 2013 at 11:30 AM
Thanks swingate56 for using this tool.

There is a condition fonctionnality on every action.
In your case, you can retrieve an attribute param "createdbyname" then on your action condition set #p{paramnumber}.ToLower() == "systemuserfullname".ToLower()
see screenshot below


Hope it helps
Jun 6, 2013 at 3:08 PM
Thank you for those details. I will be using this tool in several ongoing projects and will write a review once I have everything deployed.
I have 1 additional question.

In my case creation plug-in I need to look to see if the Email is to a specific user- your provided those details above. Then I need to determine if the From email matches an Account so I can set the Account as the Customer on the Workflow - I have this part working. What I need to add is the following.
If the To doesn't match an account, see if it matches a contact (I have the fetch xml built for this). If it matches the contact then use the Contact as the Customer on Case. If it doesn't match either Account or customer, then map to a default Account (again I have the fetch xml prepared to retrieve the default).
So, with all that said I guess I'm trying to figure out how to set CustomerID field to the Account, Contact or Default.

Again, thank you
Jun 8, 2013 at 9:52 PM
Edited Jun 8, 2013 at 11:52 PM
Hi Steve, sorry for the delayed answer, i had to set a new virtual machine for testing/debugging and it took me forever...

I just posted a new release ( to make the following works
So for your case, you can try to create :
  • an attribute param : email."to" #p1
  • a Xml param which retrieves your default contact (don't forget de choose "First" Aggregation function) #p2
  • 2 "create actions" (in the same trigger)
    the first with condition #p1.LogicalName == "contact" || #p1.LogicalName == "account"
    then you can map customerid to #p1
    the second with condition #p1.LogicalName != "contact" && #p1.LogicalName != "account"
    then you can map customerid to #p2[contactidindex]
Hope it helps,
Jul 8, 2013 at 1:41 PM
Hi - when I tried using the above logic to determine the entity logical name of the Email To, I received a mismatch error when trying to validate. Any insight as to what I may be missing?

Thanks for your help and this very helpful tool!
Jul 8, 2013 at 1:52 PM

What version are you using ? the version is not compatible with above tip.
If you're using the first version, please update it (with, and try again.

Jul 31, 2014 at 11:05 AM

Did you manage to get this working? I still cannot understand why is functionality of email body to case description is still not available out of the box on CRM 2013.

Kindly assist if you got this to work

dnachimow wrote:
Hi - when I tried using the above logic to determine the entity logical name of the Email To, I received a mismatch error when trying to validate. Any insight as to what I may be missing?

Thanks for your help and this very helpful tool!
Jul 31, 2014 at 2:11 PM
Edited Jul 31, 2014 at 2:11 PM
Hi sonzofsoil,

Please try to import this sample with the last version.
This example is very simple and creates an incident on email creation (only if "from" or "to" field is an "account" or "contact")
<?xml version="1.0" encoding="utf-16"?>
<ArrayOfXportObject xmlns:xsi="" xmlns:xsd="">
  <XportObject Name="Email To Case Test" Active="true" Entity="email" PreCreate="false" PostCreate="true" PreUpdate="false" PostUpdate="false" PreDelete="false" PostDelete="false" Synchronous="true" Order="0">
    <Rules>&lt;?xml version="1.0" encoding="utf-16"?&gt;
&lt;ArrayOfCrmRule xmlns:xsi="" xmlns:xsd=""&gt;
  &lt;CrmRule ParamNumber="1" Type="Attribute" AttributeState="After" ReturnCount="1" ReturnType="Lookup" LogicalName="to" FetchXml="" LineFunction="None" LineSeparator="" ColumnSeparator="" /&gt;
  &lt;CrmRule ParamNumber="2" Type="Attribute" AttributeState="After" ReturnCount="1" ReturnType="Lookup" LogicalName="from" FetchXml="" LineFunction="None" LineSeparator="" ColumnSeparator="" /&gt;
  &lt;CrmRule ParamNumber="3" Type="Attribute" AttributeState="After" ReturnCount="1" ReturnType="String" LogicalName="description" FetchXml="" LineFunction="None" LineSeparator="" ColumnSeparator="" /&gt;
  &lt;CrmRule ParamNumber="4" Type="Attribute" AttributeState="After" ReturnCount="1" ReturnType="String" LogicalName="subject" FetchXml="" LineFunction="None" LineSeparator="" ColumnSeparator="" /&gt;
    <Actions>&lt;?xml version="1.0" encoding="utf-16"?&gt;
&lt;ArrayOfCrmAction xmlns:xsi="" xmlns:xsd=""&gt;
  &lt;CrmAction Type="Create" MaxDepth="1" ForEachParamNumber="-1" EntityLogicalName="incident" Order="0"&gt;
      &lt;FieldExpression AttributeLogicalName="customerid" Type="Lookup" Expression="(#p2.LogicalName == &amp;quot;account&amp;quot; || #p2.LogicalName == &amp;quot;contact&amp;quot;)&amp;#xD;? #p2.Id : #p1.Id" AttributeTypeCode="Customer" Targets="account;contact" /&gt;
      &lt;FieldExpression AttributeLogicalName="description" Type="String" Expression="#p3" AttributeTypeCode="Memo" Targets="" /&gt;
      &lt;FieldExpression AttributeLogicalName="title" Type="String" Expression="#p4" AttributeTypeCode="String" Targets="" /&gt;
    &lt;ExpressionId AttributeLogicalName="" Type="None" Expression="" AttributeTypeCode="Boolean" Targets="" /&gt;
    &lt;ConditionExpression AttributeLogicalName="" Type="Boolean" Expression="#p2.LogicalName == &amp;quot;account&amp;quot; || #p2.LogicalName == &amp;quot;contact&amp;quot;&amp;#xD;||&amp;#xD;#p1.LogicalName == &amp;quot;account&amp;quot; || #p1.LogicalName == &amp;quot;contact&amp;quot;&amp;#xD;" AttributeTypeCode="Boolean" Targets="" /&gt;