KCodeR
KCodeR

Reputation: 139

Dynamics Email and Email attachments

we have requirement that when email is received in to crm with attachments ,we need to pass to API the Attachment details for that email so can be stored. does someone have the data model of how the email attachments entities are linked. As i know there is activitymimeattachment and also attachment.

Or if anyone has past experience of passing through the values to API? Thanks

Upvotes: 1

Views: 2171

Answers (1)

AnkUser
AnkUser

Reputation: 5531

If I understand your requirement correctly or I assume your requirement is to download the attachments for all the incoming Emails to CRM.

Based on assumption of Requirement,

  1. You can create an Plugin on Incoming Emails to CRM i.e on Email Entity
  2. Inside plugin Check for Email if you have an linked Entity (activitymimeattachment) join as Inner
  3. Now again link it with attachment entity join as Inner
  4. In attachment Entity you have body filed which will give you Base64 of every attachment may it be Image, Docx, Pdf and so on.
  5. Now you can convert this base64 into Image or PDF depending on filename and it's extension.

Here is the sample Fetchxml for you

<fetch>
  <entity name="email" >
    <attribute name="attachmentcount" />
    <attribute name="subject" />
    <attribute name="mimetype" />
    <link-entity name="activitymimeattachment" from="objectid" to="activityid" link-type="inner" >
      <attribute name="filename" />
      <attribute name="filesize" />
      <attribute name="attachmentid" />
      <link-entity name="attachment" from="attachmentid" to="attachmentid" link-type="inner" >
        <attribute name="body" />
      </link-entity>
    </link-entity>
  </entity>
</fetch>

Upvotes: 1

Related Questions