Skip to content

Email with Attachment from Template

With the EMailEngine, it is possible to create an e-mail with a document attached instead of returning a document to the client. After the e-mail has been generated, the system redirects to the created e-mail.

Configuration

You can create a new Text Engine for the user interface of Microsoft Dynamics CRM. To do this you need the following information:

  • Type awisto.Xrm.OfficeIntegration.Engines.Email.EMailEngine
  • Assembly awisto.Xrm.OfficeIntegration.Engines.EMail

Creating the necessary data source

The configuration of the engine takes place via additional data in the data source. It has to contain, aside from the data necessary for the document, the following structure(The GUIDs, in this case are hard coded):

<?xml version="1.0" encoding="utf-8" ?>
<data>
  <Subject></Subject>

  <!--   If the attribute Template does not contain a priary key of an OfficeIntegration Template, the Body is taken as HTML.  -->
  <Body Template="2F7E194E-8E06-4D8C-99B5-E06AE5534C8B"></Body>

  <Attachments>
    <!-- All Attachments will be automatically added to the EMail TargetType and TargetId can be omitted an default to the primary object -->
    <!-- Template = primary key of the OfficeIntegration Template -->
    <!-- TargetType = The ObjectTyp of the Document -->
    <!-- TargetID = Primary key of the target data the document applies to -->
    <Attachment
    Template="9A535F62-8E01-44D4-BA18-074CE49E7EF3" 
    TargetType="systemuser" 
    TargetId="ABA1C0DA-3D3F-4DA3-89AF-1EA4C88D170E" />
  </Attachments>

  <Recipients>
    <From>
    <!-- Type =  ObjectTyp of recipient -->
    <!-- Id = primary key of the recipient -->
    <!-- If there is no recipient, the current User will be registered as recipient -->
      <Recipient Type="systemuser" Id="79B0896F-0DC7-44AE-8050-EBF908A4C386" />
    </From>

    <To>
      <Recipient Type="contact" Id="A84D9928-8B67-4338-98CA-0C8F2EEB0BB7" />
    </To>
    <CC>
      <Recipient Type="account" Id="F109142D-3948-4B8E-A389-2E8D4BD879B6" />
    </CC>

    <BCC>
      <!-- ... -->
    </BCC>
  </Recipients>
</data>

If you want to edit the data supplied by the data source with XSLT you can just use the usual method so that the necessary data returns dynamically in the XML output.