How do I make sure that the files in an incoming email with attachments are uploaded correctly?

NishimuraChinatsu-9854 756 Reputation points
2023-04-19T09:12:24.38+00:00

I am using logic apps to upload files from incoming email attachments to a blob.  The received file is a macro enabled excel file, but when uploaded it is uploaded to the blob as a content type of text/plain; charset=utf-8n. How can I get it uploaded as the correct file? User's image

{
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {
            "For_each": {
                "actions": {
                    "Uploads_a_Blob_to_Azure_Storage": {
                        "inputs": {
                            "parameters": {
                                "blobName": "src_s/delta/excel/@{items('For_each')?['name']}",
                                "containerName": "raw",
                                "content": "@items('For_each')?['id']"
                            },
                            "serviceProviderConfiguration": {
                                "connectionName": "AzureBlob-2",
                                "operationId": "uploadBlob",
                                "serviceProviderId": "/serviceProviders/AzureBlob"
                            }
                        },
                        "runAfter": {
                            "添付ファイルの取得_(V2)": [
                                "Succeeded"
                            ]
                        },
                        "type": "ServiceProvider"
                    },
                    "添付ファイルの取得_(V2)": {
                        "inputs": {
                            "host": {
                                "connection": {
                                    "referenceName": "office365_1"
                                }
                            },
                            "method": "get",
                            "path": "/codeless/v1.0/me/messages/@{encodeURIComponent(triggerBody()?['id'])}/attachments/@{encodeURIComponent(items('For_each')?['id'])}"
                        },
                        "runAfter": {},
                        "type": "ApiConnection"
                    }
                },
                "foreach": "@triggerBody()?['attachments']",
                "runAfter": {},
                "type": "Foreach"
            }
        },
        "contentVersion": "1.0.0.0",
        "outputs": {},
        "triggers": {
            "新しいメールが届いたとき_(V3)": {
                "inputs": {
                    "fetch": {
                        "method": "get",
                        "pathTemplate": {
                            "template": "/v3/Mail/OnNewEmail"
                        },
                        "queries": {
                            "fetchOnlyWithAttachment": true,
                            "folderPath": "Id::AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=",
                            "importance": "Any",
                            "includeAttachments": true
                        }
                    },
                    "host": {
                        "connection": {
                            "referenceName": "office365_1"
                        }
                    },
                    "subscribe": {
                        "body": {
                            "NotificationUrl": "@{listCallbackUrl()}"
                        },
                        "method": "post",
                        "pathTemplate": {
                            "template": "/GraphMailSubscriptionPoke/$subscriptions"
                        },
                        "queries": {
                            "fetchOnlyWithAttachment": true,
                            "folderPath": "Id::AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=",
                            "importance": "Any"
                        }
                    }
                },
                "metadata": {
                    "Id::AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA_AAA=": "10_rcv",
                    "Id::AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=": "file_1"
                },
                "splitOn": "@triggerBody()?['value']",
                "type": "ApiConnectionNotification"
            }
        }
    },
    "kind": "Stateful"
}
Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
2,996 questions
0 comments No comments
{count} votes

Accepted answer
  1. VenkateshDodda-MSFT 19,646 Reputation points Microsoft Employee
    2023-04-19T16:02:26.5033333+00:00

    @NishimuraChinatsu-9854 Thank you for reaching out to Microsoft Q&A, apologize for any inconvenience caused on this.

    Based on shared information, it looks like you are using upload a blob to Azure storage action in built-in Azure blob storage connector in standard logic apps then the content type that will be stored as string(text/plain) only as mentioned in the documentation.

    User's image

    • As per docs, for storing Marco excel, the content type should be .xlsm -->application/vnd.ms-excel.sheet.macroEnabled.12
    • If you want to store your attachments in blob storage with above Content-type, then you need to use Azure Based Azure Blob storage connector and followed by CreateBlob(V2) to create a blob.

    Feel free to reach back to me if you have any further questions on this.


0 additional answers

Sort by: Most helpful