How to use Logic App to get/send outlook item (i.e. *.msg)
Published May 19 2021 11:13 PM 5,224 Views
Microsoft

If you tried to use logic app to pick up all attachments with “When an email is received” Office 365 trigger, we might notice that some of the attachments are not able to be retrieved from this trigger. By checking the raw output from the trigger, you might find even “hasAttachments” is “true”, the “attachments” is an empty array.

Yanbo_Deng_0-1621481133825.png

 

 

This is caused by Office 365 connector does not support “item attachment”. From our official document, we should use HTTP with Azure AD connector to work around such limitation.
Reference:
Office 365 connector limitation: https://docs.microsoft.com/en-us/connectors/office365/#known-issues-and-limitations

 

To workaround it, you could follow the steps below:

  1. First of all, using a “When a new email arrives V3” trigger to monitor if an email arrived, and get the message id of emails received. And then use HTTP to call Graph API and list attachments from the message id retrieved from the trigger.
    Reference:
    Graph API list attachments: https://docs.microsoft.com/en-us/graph/api/message-list-attachments?view=graph-rest-1.0&tabs=http
    Yanbo_Deng_1-1621481133837.png

     



  2. Then for each attachments listed from the email, we get the attachment raw contents from the attachment id. Note that we added “$value” in the request to get attachment raw contents.
    Reference:
    https://docs.microsoft.com/en-us/graph/api/attachment-get?view=graph-rest-1.0&tabs=http#example-6-ge...
    Yanbo_Deng_2-1621481133845.png

     



  3. The last step is to send this attachment in an email. We need to add an extension ".eml" to the attachment name, so our outlook could recognize it as an valid attachment.
    Yanbo_Deng_3-1621481133852.png

     

Sample:

The original email received:

Yanbo_Deng_6-1621481188589.png

 

The new email sent by logic app:

Yanbo_Deng_5-1621481133861.png

 

 

Co-Authors
Version history
Last update:
‎May 19 2021 11:08 PM
Updated by: