web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Can I attach JSON as a...
Power Apps
Unanswered

Can I attach JSON as a file to an email from Power Apps?

(0) ShareShare
ReportReport
Posted on by 56

I want to send an email from Power Apps with the data recorded in the app formatted as JSON and attached as a .json file on the email. I also want to attach any pictures taken. I have been following Shane Young's video (https://www.youtube.com/watch?v=V3feURQfY3M) for how to attach the pictures, which works very well. But I have not been able to attach the JSON as a file to the email.

 

Copying how pictures are sent as attachments I have tried putting in JSON as:

 

{
    Name: "test.json",

    ContentBytes: 'The Formatted JSON',
    '@odata.type': I have tried a few different odata types but nothing worked
}

 

I can put the JSON in the body of the email but ideally, we would like is as a file. Does anyone know if this can be done? Or is it a limitation with the connection or Power Apps?

 

- Note: I am using the Office365.SendEmailV2 connection and it works perfectly for pictures. 

Categories:
I have the same question (0)
  • v-siky-msft Profile Picture
    on at

    Hi @DerekHurley 

     

    How did you define the 'The Formatted JSON'?

    The ContentBytes should be Blob URL, e.g.  appres://blobmanager/4cc184e7f90b4f5781a498cec7a161d4/1

    Please refer to this video: https://www.youtube.com/watch?v=Ws6xEr5N1cU 

     

    If you want to convert the Data to Blob URL, I am afraid it is not supported in PowerApps.

    If you want this feature, please submit an idea to PowerApps Ideas Forum. https://powerusers.microsoft.com/t5/Power-Apps-Ideas/idb-p/PowerAppsIdeas 

    Sik

  • DerekHurley Profile Picture
    56 on at

    Hi @v-siky-msft ,

     

    Thanks for the response.

     

    Here is (a shortened version of) what I have in Power Apps:

    JSON(
     {
     GUID: gblReferenceGUID,
     author_name: cmbName.Selected.DisplayName,
     created_date_time: Now(),
     Region: drpRegion.Selected.Value,
     Site: txtSite.Text,
     section1: {
     name: "induction",
     values: {
     result_value: gblSiteInduction,
     result_schema: "traffic_light",
     result_text: txtSiteInductionComments.Text
     }
     },
     section2: {
     name: "documentation",
     values: {
     result_value: gblDocuments,
     result_schema: "traffic_light",
     result_text: txtDocumentsComments.Text
     }
     }
     },
     JSONFormat.IndentFour
    )

     Which results in:

    {
     "GUID": "a6ced1d9-61eb-4bf2-b2ea-68c8ffb9bbaa",
     "Region": "EUAF",
     "Site": "Perth",
     "author_name": "Derek Hurley",
     "created_date_time": "2020-02-21T05:53:13.071Z",
     "section1": {
     "name": "induction",
     "values": {
     "result_schema": "traffic_light",
     "result_text": null,
     "result_value": "Good"
     }
     },
     "section2": {
     "name": "documentation",
     "values": {
     "result_schema": "traffic_light",
     "result_text": "Test comments",
     "result_value": "Bad"
     }
     }
    }

     

    The above JSON is what I put into ContentBytes. What I am trying to do is send the above JSON (which is a text string) as a .json file attached to an email. 

     

    I have done this with pictures, is there a way to do it for JSON?

     

    Thanks.

  • v-siky-msft Profile Picture
    on at

    @DerekHurley 

    The codes just convert the data to JSON type, but the ContentBytes requires the Blob URL of Files. 

    I come up with an idea that use AzureBlobStorage connector to create JSON file into blob storage, and then recall the JSON File Blob URL in ContentBytes parameter.  Reference: create block blob, get blob content 

    AzureBlobStorage.CreateBlockBlob(<folderpath>,"Name.JSON",JSON("ABC"),{'Content-Type':"application/json"})
    AzureBlobStorage.GetFileContent(<JSONFileBlobID>)
    Office365Outlook.SendEmailV2("v-sikyan@microsoft.com","Subject goes here","Body goes here",{Attachments:Table({
    Name: "Test.JSON",ContentBytes:<JSONFileBlobURL>,'@odata.type':""})})

    I cannot verify this idea since my Azure subscription expired.

    If it doesn't work, please submit a ticket to Microsoft for further assistance.

    https://admin.powerplatform.microsoft.com/support 

    Sik

     

  • Verified answer
    v-siky-msft Profile Picture
    on at

    .Hi @DerekHurley ,

     

    Has your issue resolved?

    I just find a workaround for your case via Flow. Let's create a flow:

    1. create a PowerApps instant flow

    2. Add 'Compose' action, set Input: Ask in PowerApp, get the JSON passed from PowerApps

    3. Add 'Create File' from OneDrive for business action, select the Folder Path, enter the File Name, select File Content to Outputs of previous 'Compose' action.

    4. Add 'Get file content' action, Set File: Id of previous 'Create File' action

    5. Add 'Send an email (V2)' action, Set To, Subject and Body, enter Attachment Name, Select Attachment Content: File Content of previous 'Get file content' action.

     

    Then add the flow into PowerApps, apply the Json result into the flow run code.

     

    FlowName.Run( JSON(
    {
    GUID: gblReferenceGUID,
    author_name: cmbName.Selected.DisplayName,
    created_date_time: Now(),
    Region: drpRegion.Selected.Value,
    Site: txtSite.Text,
    section1: {
    name: "induction",
    values: {
    result_value: gblSiteInduction,
    result_schema: "traffic_light",
    result_text: txtSiteInductionComments.Text
    }
    },
    section2: {
    name: "documentation",
    values: {
    result_value: gblDocuments,
    result_schema: "traffic_light",
    result_text: txtDocumentsComments.Text
    }
    }
    },
    JSONFormat.IndentFour
    ))

     

    Flow steps:

    Snipaste_2020-03-09_12-06-32.png

    Test Result:

    Snipaste_2020-03-09_12-18-17.png

    Sik

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard