Writing Email Attachments to Common Data Service Notes Entity
  • 14 Oct 2020
  • 1 Minute To Read
  • Contributors
  • Print
  • Comments
  • Share
  • Dark
    Light

Writing Email Attachments to Common Data Service Notes Entity

  • Print
  • Comments
  • Share
  • Dark
    Light

#ServerlessTips - Power Automate
Author: Kent Weare Integration MVP

A common scenario when you are managing customers is the ability to receive email attachments from them and then be able to add them to your Customer Relationship Management (CRM) system such as Dynamics 365. This allows you to centralize all communications from your customer and make it easy to find it.
1-CDS

We can automate this process of adding attachments from our customer by using Power Automate and that will be the focus of this post.

  1. To start with, we will use the Office 365 Outlook connector and the When a new email arrives (V3) trigger. As part of our trigger configuration, we need to set Include Attachments to Yes and Only with Attachments to Yes. This will ensure we only process emails that have attachments.

2-EmailTrigger

  1. Next, we will add the Common Data Service (current environment) connector and the Create a new record action.

3-CDSNewRecord

  1. We now need to configure this action and will do so by assigning the following values:
    Entity name – Notes
    Title – New Attachment (or whatever value you prefer)
    Description – New Attachment (or whatever value you prefer)
    Is Document – Yes
    Document - Here we will use an expression of: decodeBase64(base64(items('Apply_to_each')?['contentBytes']))
    File Name – Attachments Name
    File Name – Attachments Name
    Mime Type – Attachments Content Type
    4-CDSConfig

Testing

We can now go ahead and test our flow by sending in an email attachment to the inbox that our Power Automate flow is monitoring. When we process this email, we will discover that a new record has been added to our Note entity and that our attachment is available.

5 - result

Special thanks to Phil Topness who helped me troubleshoot this scenario.

Was This Article Helpful?