Search code examples
azuregmailazure-logic-apps

How to work with Gmail attachments on Azure Logic App


I have created a Logic app where I get emails from a Gmail Account and I want to post the attachment of the email to my rest API. But I don't understand which type I get as the attachment. I have seen: if I use the Outlook.com trigger I get a base64String but from Gmail I get something else. Is there an example how to work with Gmail attachments.

enter image description here


Solution

  • Thanks for the input SahadevSinh. I have changed my workflow like this: enter image description here

    And in my endpoint I do this:

     public async System.Threading.Tasks.Task<MissionOutputDto> CreateMissionFromMail(HttpRequestMessage req)
        {
            string body = await req.Content.ReadAsStringAsync();
            dynamic fileData = JObject.Parse(body);
            string email = fileData.email;
            JArray files = fileData.files;
    
            string fileString = null;
            string fileName = null;
            string mimeType = null;
    
            foreach (dynamic file in files)
            {
                fileString = file.ContentBytes;
                fileName = file.Name;
                mimeType = file.ContentType;
            }