Send Intro Email on Lead Conversion

If you have one person working the leads (i.e. Telemarketer) and another on qualified opportunities (Salesperson) you will probably have a process like this whenever a Telemarketer decides to convert the Lead to Opportunity:

  1. Assign the Lead to the Salesperson

  2. Send an introductory email FROM the Salesperson to the Lead

  3. Convert the Lead

  4. Notify the Salesperson via email of the new opportunity assigned to them (click here for the article on how to do that)

On step number 2, while it's possible for the Telemarketer to send the email manually, it would be helpful if the email was fired off automatically.  A regular workflow rule can do that but it sends the email from the owner of the rule (typically System Administrator).  We want it to come from the Salesperson and more importantly to merge in data fields from the Salesperson's user entity such his/her direct phone number.  It's possible to do this with a Workflow rule and a custom workflow assembly.

You can create such a rule in Microsoft CRM 3.0 by following these steps:

  1. Download AM.CrmSendTemplateEmailAs.dll and place it into the "C:\Program Files\Microsoft CRM\Server\bin\assembly" directory.

  2. Stop the Microsoft CRM Workflow Service.  Edit the workflow.config file in the same directory (see very bottom) or if you haven't made any other customizations to it, you can just replace it with this download: workflow.config (our version includes the default entries from MS CRM 3.0 plus all our workflow assembly registrations from this and other articles).  Start the service.

  3. You can now import the rule using the Microsoft CRM Import Workflow Wizard from this file: CRMWorkflow.SendIntroEmailOnLeadConversion.xml

  4. Open the rule in Workflow manager under Leads - Edit the 'Send Template Email As Entity Owner to Lead ...' action - double-click on TemplateId and select the template you wish to use (we have it set to some Lead template that comes with CRM)

  5. Activate the rule (to make modifications, rule must be deactivated)

Note that the code in the workflow assembly is a slightly modified version of:
http://blogs.msdn.com/crm/.../sending-email-via-workflow-as-different-user.aspx

The custom workflow assembly is actually rather generic and will send an email using the specified template on behalf of the specified user or even a CRM queue.  However, because of the way the workflow engine works, the assembly has to be individually configured for each entity to which you want to send an email and it has to be configured twice - once to send on behalf of a user, another on behalf of a queue.  The following XML from our workflow.config sets up two groups of custom actions under Call assembly:  Send Template Email As Queue and Send Template Email As Owner.  In each group, there are three actions for Contact, Lead, and Account:

<method name="Send Template Email As Queue to Contact"
 assembly="AM.CRMSendTemplateEmailAs.dll"
 typename="AM.SendTemplateEmailAsAssembly" methodname="SendTemplateEmailAs"
 group="Send Template Email As Queue">
    <parameter name="callerXml" datatype="caller"/>
    <parameter name="SenderId" datatype="lookup" entityname="queue"/>
    <parameter name="SenderType" datatype="string" default="queue"/>
    <parameter name="RecipientId" datatype="lookup" entityname="contact"/>
    <parameter name="RecipientType" datatype="string" default="contact"/>
    <parameter name="TemplateId" datatype="lookup" entityname="template"/>
</method>
<method name="Send Template Email As Queue to Lead"
 assembly="AM.CRMSendTemplateEmailAs.dll"
 typename="AM.SendTemplateEmailAsAssembly" methodname="SendTemplateEmailAs"
 group="Send Template Email As Queue">
    <parameter name="callerXml" datatype="caller"/>
    <parameter name="SenderId" datatype="lookup" entityname="queue"/>
    <parameter name="SenderType" datatype="string" default="queue"/>
    <parameter name="RecipientId" datatype="lookup" entityname="lead"/>
    <parameter name="RecipientType" datatype="string" default="lead"/>
    <parameter name="TemplateId" datatype="lookup" entityname="template"/>
</method>
<method name="Send Template Email As Queue to Account"
 assembly="AM.CRMSendTemplateEmailAs.dll"
 typename="AM.SendTemplateEmailAsAssembly" methodname="SendTemplateEmailAs"
 group="Send Template Email As Queue">
    <parameter name="callerXml" datatype="caller"/>
    <parameter name="SenderId" datatype="lookup" entityname="queue"/>
    <parameter name="SenderType" datatype="string" default="queue"/>
    <parameter name="RecipientId" datatype="lookup" entityname="account"/>
    <parameter name="RecipientType" datatype="string" default="account"/>
    <parameter name="TemplateId" datatype="lookup" entityname="template"/>
</method>
<method name="Send Template Email As Entity Owner to Contact"
 assembly="AM.CRMSendTemplateEmailAs.dll"
 typename="AM.SendTemplateEmailAsAssembly" methodname="SendTemplateEmailAs"
 group="Send Template Email As Owner">
    <parameter name="callerXml" datatype="caller"/>
    <parameter name="SenderId" datatype="lookup" entityname="systemuser"/>
    <parameter name="SenderType" datatype="string" default="systemuser"/>
    <parameter name="RecipientId" datatype="lookup" entityname="contact"/>
    <parameter name="RecipientType" datatype="string" default="contact"/>
    <parameter name="TemplateId" datatype="lookup" entityname="template"/>
</method>
<method name="Send Template Email As Entity Owner to Lead"
 assembly="AM.CRMSendTemplateEmailAs.dll"
 typename="AM.SendTemplateEmailAsAssembly" methodname="SendTemplateEmailAs"
 group="Send Template Email As Owner">
    <parameter name="callerXml" datatype="caller"/>
    <parameter name="SenderId" datatype="lookup" entityname="systemuser"/>
    <parameter name="SenderType" datatype="string" default="systemuser"/>
    <parameter name="RecipientId" datatype="lookup" entityname="lead"/>
    <parameter name="RecipientType" datatype="string" default="lead"/>
    <parameter name="TemplateId" datatype="lookup" entityname="template"/>
</method>
<method name="Send Template Email As Entity Owner to Account"
 assembly="AM.CRMSendTemplateEmailAs.dll"
 typename="AM.SendTemplateEmailAsAssembly" methodname="SendTemplateEmailAs"
 group="Send Template Email As Owner">
    <parameter name="callerXml" datatype="caller"/>
    <parameter name="SenderId" datatype="lookup" entityname="systemuser"/>
    <parameter name="SenderType" datatype="string" default="systemuser"/>
    <parameter name="RecipientId" datatype="lookup" entityname="account"/>
    <parameter name="RecipientType" datatype="string" default="account"/>
    <parameter name="TemplateId" datatype="lookup" entityname="template"/>
</method>

Because our assembly dll is unsigned, to use it, you must have the allowunsignedassemblies attribute set in the root node (top-most tag) of this XML file:

<workflow.config xmlns="http://microsoft.com/mscrm/workflow/"
  allowunsignedassemblies="true" >

Finally, our workflow rule is set up to fire whenever a Lead's status is changed to Qualified.  You could add additional conditions if desired.

Note: if you want to manually invoke a rule configured to send email on behalf of a queue, the user launching the rule will need "append to" privileges for queues.

 

© Copyright 1996-2014 by am.net and Solitex Networks. Legal Notices.
Creative Commons License Articles on this site are licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.