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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Power Apps SendEmailV2...
Power Apps
Answered

Power Apps SendEmailV2 Error

(0) ShareShare
ReportReport
Posted on by 5,331 Moderator
A user is getting the following error message when clicking the save button in a Power Apps screen.

Office365Outlook.SendEmailV2 failed: Error - code 400 Bad Request - Attachment name and content bytes cannot be null or empty.




The save button has the following formula, with is sending an email and three attachments. My guess is the error is regarding one, or more, of the 'Attachments' was missing
content for 'name' and/or 'contentBytes'. In the process a report is always required, as well as at least one 'Track Photo'. My guess is the user didn't not add content for the
'Additional Photos', and this is what is causing the 'null or empty' error.

Is there a way to account for empty "PDFBlob" (attachment name and contentBytes) in the formula for the 'Additional Photos' and 'Track Photos' component, that will allow the
flow to run without error?
 
If(
    IS_Inspection_Type_TI.Text = "Walking Inspection",
    Office365Outlook.SendEmailV2(
        IS_Client_Email_Address_TI.Text,
        IS_Inspection_Type_TI.Text,
        "To Whom it May Concern:" & "<br><br>" &
        "A Walking Inspection was conducted at " & IS_Site_Location_TI.Text & "." & "<br><br>" &
        "Please find attached the inspection report." & "<br><br>" &
        "If you have any questions, you can contact Joe, Rail Inspector, at, " & IS_Client_Email_Address_TI.Text,
        {
            Cc: IS_Client_Email_Address_TI.Tex,
            Attachments: Table(
                {
                    Name: "InspectionReport.pdf",
                    ContentBytes: varInspectionReportPDFBlob
                },
                {
                    Name: "TrackPhotosReport.pdf",
                    ContentBytes: varTrackPhotosReportPDFBlob
                },
                {
                    Name: "AdditionalPhotosReport.pdf",
                    ContentBytes: varAdditionalPhotosReportPDFBlob
                }
            )
        }
    )
);
Categories:
I have the same question (0)
  • Suggested answer
    Pstork1 Profile Picture
    69,169 Most Valuable Professional on at
    Instead of trying to account for an empty entry why not build the table as a Collection first and then add the collection as the Attachments entry.  Doing that would make it easier to account for a variable number of Attachments.

    ----------------------------------------------------------------------------------
    If this Post helped you, please click "Does this answer your question" and give it a like to help others in the community find the answer too!

    Paul Papanek Stork, MVP
    Blog: https://www.dontpapanic.com/blog
     
  • Phineas Profile Picture
    5,331 Moderator on at
    @Pstork1

    This concept is beyond my understanding.

    How would I place the three 'Blob' items into a collection. I tried this, in the 'OnVisible' or my screen,
    but I got an error message -
    col_PDF_Reports - There is an error in this formula. Trying to revise the formula and running again.
     
    ClearCollect(
        col_PDF_Reports,
    {name: "InspectionReport.pdf", contentBytes: varInspectionReportPDFBlob},
    {name: "TrackPhotosReport.pdf", contentBytes: varTrackPhotosReportPDFBlob},
    {name: "AdditionalPhotosReport.pdf", contentBytes: varAdditionalPhotosReportPDFBlob})

    Can you demonstrate?

    Currently, the email is sending the separate attachments -
    1. The Inspection and Invoice report
    2. The Track Photos report
    3. Additional Photos report

    Would creating a collection send all reports (files) as a single PDF report (file)?

    Here is the screen with the save button (which contains the formula we are discussing), and the three PDF Viewer controls.

  • Pstork1 Profile Picture
    69,169 Most Valuable Professional on at
    I'll try to help, but I need more information.  Where are the PDF blobs coming from that you are displaying in the PDF viewers?

    ----------------------------------------------------------------------------------
    If this Post helped you, please click "Does this answer your question" and give it a like to help others in the community find the answer too!

    Paul Papanek Stork, MVP
    Blog: https://www.dontpapanic.com/blog
     
  • Suggested answer
    Phineas Profile Picture
    5,331 Moderator on at
    @Pstork1

    I believe I got it.

    At the 'OnVisible' of a screen I have -
    ClearCollect(
        col_PDF_Reports,
    {name: "InspectionReport.pdf", contentBytes: varInspectionReportPDFBlob},
    {name: "TrackPhotosReport.pdf", contentBytes: varTrackPhotosReportPDFBlob},
    {name: "AdditionalPhotosReport.pdf", contentBytes: varAdditionalPhotosReportPDFBlob})

    In the Save and Email button I have -
    If(
        IS_Inspection_Type_TI.Text = "Walking Inspection",
        Office365Outlook.SendEmailV2(
            IS_Client_Email_Address_TI.Text,
            IS_Inspection_Type_TI.Text,
            "To Whom it May Concern:" & "<br><br>" &
            "A Walking Inspection was conducted at " & IS_Site_Location_TI.Text & "." & "<br><br>" &
            "Please find attached the inspection report." & "<br><br>" &
            "If you have any questions, you can contact Jill, Rail Inspector, at " & IS_Inspector_Email_Address_TI.Text,
            {
                Cc: "JollyRancher@acmerailagency.onmicrosoft.com",
                Attachments: [
                    {
                        Name: "InspectionReport.pdf",
                        ContentBytes: LookUp(col_PDF_Reports, name = "InspectionReport.pdf").contentBytes
                    },
                    {
                        Name: "TrackPhotosReport.pdf",
                        ContentBytes: LookUp(col_PDF_Reports, name = "TrackPhotosReport.pdf").contentBytes
                    },
                    {
                        Name: "AdditionalPhotosReport.pdf",
                        ContentBytes: LookUp(col_PDF_Reports, name = "AdditionalPhotosReport.pdf").contentBytes
                    }
                ]
            }
        )
    );
  • Verified answer
    Pstork1 Profile Picture
    69,169 Most Valuable Professional on at

    ----------------------------------------------------------------------------------
    If this Post helped you, please click "Does this answer your question" and give it a like to help others in the community find the answer too!

    Paul Papanek Stork, MVP
    Blog: https://www.dontpapanic.com/blog
    That will work, but you shouldn't need the lookup after you add the files to the collection.  Instead just pass the collection.
    If(
        IS_Inspection_Type_TI.Text = "Walking Inspection",
        Office365Outlook.SendEmailV2(
            IS_Client_Email_Address_TI.Text,
            IS_Inspection_Type_TI.Text,
            "To Whom it May Concern:" & "<br><br>" &
            "A Walking Inspection was conducted at " & IS_Site_Location_TI.Text & "." & "<br><br>" &
            "Please find attached the inspection report." & "<br><br>" &
            "If you have any questions, you can contact Jill, Rail Inspector, at " & IS_Inspector_Email_Address_TI.Text,
            {
                Cc: "JollyRancher@acmerailagency.onmicrosoft.com",
                Attachments: col_PDF_Reports
            }
        )
    );
     
     
  • Phineas Profile Picture
    5,331 Moderator on at
    @Pstork1

    I think I almost got it.

    I am creating a Collection at 'OnVisible' of my screen. Here are my collection and the formula.

    OnVisible PDF Blob Collection formula - 
    ClearCollect(
        col_PDF_Reports,
          {name: "InspectionReport.pdf", contentBytes: varInspectionReportPDFBlob},
          {name: "TrackPhotosReport.pdf", contentBytes: varTrackPhotosReportPDFBlob},
          {name: "AdditionalPhotosReport.pdf", contentBytes: varAdditionalPhotosReportPDFBlob})

    PDF Reports Collections -


    My 'Save and Email' button contains (as an example) -
    If(
        IS_Inspection_Type_TI.Text = "Walking Inspection",
        Office365Outlook.SendEmailV2(
            IS_Client_Email_Address_TI.Text,
            IS_Inspection_Type_TI.Text,
            "To Whom it May Concern:" & "<br><br>" &
            "A Walking Inspection was conducted at " & IS_Site_Location_TI.Text & "." & "<br><br>" &
            "Please find attached the inspection report." & "<br><br>" &
            "If you have any questions, you can contact Joe Schmoe, Rail Inspector, at " &
             IS_Inspector_Email_Address_TI.Text,

            {
                Cc: "Joeschmoe@acmerailagency.onmicrosoft.com",
                Attachments: [
                    {
                        Name: "InspectionReport.pdf",
                        ContentBytes: LookUp(col_PDF_Reports, name =
                        "InspectionReport.pdf").contentBytes

                    },
                    {
                        Name: "TrackPhotosReport.pdf",
                        ContentBytes: LookUp(col_PDF_Reports, name =
                        "TrackPhotosReport.pdf").contentBytes

                    },
                    {
                        Name: "AdditionalPhotosReport.pdf",
                        ContentBytes: LookUp(col_PDF_Reports, name =
                        "AdditionalPhotosReport.pdf").contentBytes

                    }
                ]
            }
        )
    );

    I am getting the email, and the 'InspectionReport' is visible and can be opened as attachment. However, the TrackPhoto and AdditionalPhoto
    are not visible and do not open as an attachment, even though the documents appear to be present in the email.


     
  • Verified answer
    Power Platform 1919 Profile Picture
    2,205 Super User 2026 Season 1 on at
    Hi @,
    Please try this :
    Sample Call: (Please ignore the set statements , this is just for my testing and debugging purposes)
    Set(
        pdf_test_1,
        PDF(Container1)
    );
    Set(
        pdf_test_2,
        PDF(Container2)
    );
    Set(
        pdf_test_2,
        Blank()
    );
    Set(
        pdf_test_3,
        PDF(Container3)
    );
    Office365Outlook.SendEmailV2(
        "user1@dummy.com",
        "pdf container",
        "test pdf-1,2,3",
        {
            Attachments: With(
                {
                    _files: Table(
                        {
                            Name: "container1.pdf",
                            ContentBytes: pdf_test_1
                        },
                        {
                            Name: "container2.pdf",
                            ContentBytes: pdf_test_2
                        },
                        {
                            Name: "container3.pdf",
                            ContentBytes: pdf_test_3
                        }
                    )
                },
                Filter(
                    _files,
                    !IsBlankOrError(ContentBytes)
                )
            )
        }
    )
    Ultimately, i am filtering the files based on the condition (contentbytes is not empty).
     Sample Output:  ( This would only send container1, container3 only as my Container2 content is empty)

     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 602

#2
WarrenBelz Profile Picture

WarrenBelz 473 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 310

Last 30 days Overall leaderboard