Search code examples
emailsharepointazure-logic-apps

Logic Apps: How to save file from email onto sharepoint


In the below workflow, when an email arrives I want it to save the contents into a SharePoint folder. The workflow is successful, however the file becomes broken/ does not work because attachments content is a giant hash. There is nothing wrong with the file.

enter image description here


Solution

  • I got the same error when i used attachment content directly in the "create file" action. These series of steps helped in accessing the content:

    1. Use "Get folder metadata using path" action. I specified the file within the folder path as well such that the folder path encompasses the attachment name within the folder path.
    • This is obviously going to fail but we'll handle this error through a scope function.
    1. Use the "Scope" function to check if the attachment exists setting the prev action has failed as a requirement. Once it has failed, it will create the attachment within the specified folder path, file name and file content.

    This step includes 2 additional steps prior to creating the file and is mainly done through (1) getting the folder metadata (2) error handling through a scope function.

    enter image description here