powerappspowerapps-formula

PowerApps - Email not being sent on button submission


I am trying to have an Outlook email sent on submission of a Powerapps form. It has a few fields to gather data, including a date and attachment. However the email is not being sent after clicking on the button I have setup.

I have verified that I am able to have an email sent using the Outlook connector through a normal Powerautomate flow.

I have this code set to OnSelect of the button: ` If(

!IsBlank(DataCardValue2.SelectedItems) && !IsBlank(TextInput4.Text) && !IsBlank(DataCardValue3.Text) && !IsBlank(DataCardValue4.Text) && !IsBlank(DataCardValue5.SelectedDate),

Office365Outlook.SendEmailV2(

    "email@domain.com",

    "Subject: Form Submission Test",

    "Value1: " & Concat(DataCardValue2.SelectedItems, Value & ", ") & Char(10) &

    "Value2: " & TextInput4.Text & Char(20) &

    "Value3: " & DataCardValue3.Text & Char(20) &

    "Value4 " & DataCardValue4.Text & Char(10) &

    "Date: " & Text(DataCardValue5.SelectedDate, "mm/dd/yyyy"),

    {

        Attachments: ForAll(DataCardValue7.Attachments, {Name: Name, ContentBytes: Value, '@odata.type': "#microsoft.graph.fileAttachment"})

    }

)

);

SubmitForm(Form1);

Navigate(Screen3)`

I have verified that I am able to have an email sent using the Outlook connector through a normal Powerautomate flow.


Solution

  • I guess the issue lies around your attachment attribute, as attachment expects the value in tabular format. You can update your logic to something like this:

    Office365Outlook.SendEmailV2(
        "email@domain.com",
        "Subject: Form Submission Test",
        "Value1: " & Concat(DataCardValue2.SelectedItems, Value & ", ") & Char(10) &
        "Value2: " & TextInput4.Text & Char(20) &
        "Value3: " & DataCardValue3.Text & Char(20) &
        "Value4 " & DataCardValue4.Text & Char(10) &
        "Date: " & Text(DataCardValue5.SelectedDate, "mm/dd/yyyy"),
        {
            Attachments: Table( ForAll(DataCardValue7.Attachments, {Name: Name, ContentBytes: Value, '@odata.type': "#microsoft.graph.fileAttachment"}))
        }
    )