How to use Logic App to get/send outlook item (i.e. *.msg)

Published 05-19-2021 11:13 PM 801 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

 

 

%3CLINGO-SUB%20id%3D%22lingo-sub-2370807%22%20slang%3D%22en-US%22%3EHow%20to%20use%20Logic%20App%20to%20get%2Fsend%20outlook%20item%20(i.e.%20*.msg)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2370807%22%20slang%3D%22en-US%22%3E%3CP%3EIf%20you%20tried%20to%20use%20logic%20app%20to%20pick%20up%20all%20attachments%20with%20%E2%80%9CWhen%20an%20email%20is%20received%E2%80%9D%20Office%20365%20trigger%2C%20we%20might%20notice%20that%20some%20of%20the%20attachments%20are%20not%20able%20to%20be%20retrieved%20from%20this%20trigger.%20By%20checking%20the%20raw%20output%20from%20the%20trigger%2C%20you%20might%20find%20even%20%E2%80%9ChasAttachments%E2%80%9D%20is%20%E2%80%9Ctrue%E2%80%9D%2C%20the%20%E2%80%9Cattachments%E2%80%9D%20is%20an%20empty%20array.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Yanbo_Deng_0-1621481133825.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F282054i47750F19B6E65416%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Yanbo_Deng_0-1621481133825.png%22%20alt%3D%22Yanbo_Deng_0-1621481133825.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20is%20caused%20by%20Office%20365%20connector%20does%20not%20support%20%E2%80%9Citem%20attachment%E2%80%9D.%20From%20our%20official%20document%2C%20we%20should%20use%20HTTP%20with%20Azure%20AD%20connector%20to%20work%20around%20such%20limitation.%3CBR%20%2F%3EReference%3A%20%3CBR%20%2F%3EOffice%20365%20connector%20limitation%3A%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fconnectors%2Foffice365%2F%23known-issues-and-limitations%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fconnectors%2Foffice365%2F%23known-issues-and-limitations%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETo%20workaround%20it%2C%20you%20could%20follow%20the%20steps%20below%3A%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EFirst%20of%20all%2C%20using%20a%20%E2%80%9CWhen%20a%20new%20email%20arrives%20V3%E2%80%9D%20trigger%20to%20monitor%20if%20an%20email%20arrived%2C%20and%20get%20the%20%3CSTRONG%3Emessage%20id%3C%2FSTRONG%3E%20of%20emails%20received.%20And%20then%20use%20HTTP%20to%20call%20Graph%20API%20and%20list%20attachments%20from%20the%20%3CSTRONG%3Emessage%20id%3C%2FSTRONG%3E%20retrieved%20from%20the%20trigger.%3CBR%20%2F%3EReference%3A%20%3CBR%20%2F%3EGraph%20API%20list%20attachments%3A%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fgraph%2Fapi%2Fmessage-list-attachments%3Fview%3Dgraph-rest-1.0%26amp%3Btabs%3Dhttp%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fgraph%2Fapi%2Fmessage-list-attachments%3Fview%3Dgraph-rest-1.0%26amp%3Btabs%3Dhttp%3C%2FA%3E%20%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Yanbo_Deng_1-1621481133837.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F282055iE5BCFD792B0FA0FD%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Yanbo_Deng_1-1621481133837.png%22%20alt%3D%22Yanbo_Deng_1-1621481133837.png%22%20%2F%3E%3C%2FSPAN%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLI%3E%0A%3CLI%3EThen%20for%20each%20attachments%20listed%20from%20the%20email%2C%20we%20get%20the%20attachment%20raw%20contents%20from%20the%20%3CSTRONG%3Eattachment%20id%3C%2FSTRONG%3E.%20Note%20that%20we%20added%20%E2%80%9C%24value%E2%80%9D%20in%20the%20request%20to%20get%20attachment%20raw%20contents.%3CBR%20%2F%3EReference%3A%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fgraph%2Fapi%2Fattachment-get%3Fview%3Dgraph-rest-1.0%26amp%3Btabs%3Dhttp%23example-6-get-the-raw-contents-of-a-file-attachment-on-a-message%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fgraph%2Fapi%2Fattachment-get%3Fview%3Dgraph-rest-1.0%26amp%3Btabs%3Dhttp%23example-6-get-the-raw-contents-of-a-file-attachment-on-a-message%3C%2FA%3E%20%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Yanbo_Deng_2-1621481133845.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F282053i0015EA7E3D750837%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Yanbo_Deng_2-1621481133845.png%22%20alt%3D%22Yanbo_Deng_2-1621481133845.png%22%20%2F%3E%3C%2FSPAN%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLI%3E%0A%3CLI%3EThe%20last%20step%20is%20to%20send%20this%20attachment%20in%20an%20email.%20We%20need%20to%20add%20an%20extension%20%22.eml%22%20to%20the%20attachment%20name%2C%20so%20our%20outlook%20could%20recognize%20it%20as%20an%20valid%20attachment.%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Yanbo_Deng_3-1621481133852.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F282057iCF929FDFFD58E6EC%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Yanbo_Deng_3-1621481133852.png%22%20alt%3D%22Yanbo_Deng_3-1621481133852.png%22%20%2F%3E%3C%2FSPAN%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3ESample%3A%3C%2FP%3E%0A%3CP%3EThe%20original%20email%20received%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Yanbo_Deng_6-1621481188589.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F282059i01A7E880C85A3A75%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Yanbo_Deng_6-1621481188589.png%22%20alt%3D%22Yanbo_Deng_6-1621481188589.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20new%20email%20sent%20by%20logic%20app%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Yanbo_Deng_5-1621481133861.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F282056iFA082BEF2F9367FE%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Yanbo_Deng_5-1621481133861.png%22%20alt%3D%22Yanbo_Deng_5-1621481133861.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-2370807%22%20slang%3D%22en-US%22%3E%3CP%3EIf%20you%20tried%20to%20use%20logic%20app%20to%20pick%20up%20all%20attachments%20with%20%E2%80%9CWhen%20an%20email%20is%20received%E2%80%9D%20Office%20365%20trigger%2C%20we%20might%20notice%20that%20some%20of%20the%20attachments%20are%20not%20able%20to%20be%20retrieved%20from%20this%20trigger.%20Those%20attachments%20are%20called%20%22item%20attachment%22.%20This%20article%20is%20a%20workaround%20for%20Logic%20App%20to%20get%2Fsend%20outlook%20item%20attachment.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2370807%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ELogic%20Apps%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Co-Authors
Version history
Last update:
‎May 19 2021 11:08 PM
Updated by: