Good morning, everyone!
I am beginner and i am making a power app to send email with multi attachment.
I have 5 attachment controls.
It is work for send email with 1 attachment control, below is my code
Office365Outlook.SendEmailV2(
"alan@c.com.hk",
"Subject",
"Body",
{
Attachments: ForAll(
Attachment_Inspection_Record.Attachments,
{
ContentBytes: Value,
Name: Name
}
)
})
But it is causing error if send email with 5 attachment control attachment, below is my code:
Office365Outlook.SendEmailV2(
"alan@c.com.hk",
"Subject",
"Body",
{
Attachments: ForAll(
Attachment_Inspection_Record.Attachments,
{
ContentBytes: Value,
Name: Name
},
Attachment_CCM.Attachments,
{
ContentBytes: Value,
Name: Name
},
Attachment_Sitephoto_1.Attachments,
{
ContentBytes: Value,
Name: Name
}
Attachment_Sitephoto_2.Attachments,
{
ContentBytes: Value,
Name: Name
}
Attachment_Sitephoto_3.Attachments,
{
ContentBytes: Value,
Name: Name
}
)
});
Would anyone can help? Thank you very much.
The ForAll
function can be used to transform a table into another - but what you are trying to do is to combine (union) multiple tables, which is not what it does. You can use the Table
function to do that - either combining all the attachment controls at first, then using ForAll to extract the name/content, or combining the extracted values that you have working for one control.
For example, the first option would be similar to the expression below:
Office365Outlook.SendEmailV2(
"alan@c.com.hk",
"Subject",
"Body",
{
Attachments: ForAll(
Table(
Attachment_Inspection_Record.Attachments,
Attachment_CCM.Attachments,
Attachment_Sitephoto_1.Attachments,
Attachment_Sitephoto_2.Attachments,
Attachment_Sitephoto_3.Attachments
),
{
ContentBytes: Value,
Name: Name
}
)
}
);
While the second would be similar to this:
Office365Outlook.SendEmailV2(
"alan@c.com.hk",
"Subject",
"Body",
{
Attachments: Table(
ForAll(
Attachment_Inspection_Record.Attachments,
{
ContentBytes: Value,
Name: Name
}
),
ForAll(
Attachment_CCM.Attachments,
{
ContentBytes: Value,
Name: Name
}
),
ForAll(
Attachment_Sitephoto_1.Attachments,
{
ContentBytes: Value,
Name: Name
}
),
ForAll(
Attachment_Sitephoto_2.Attachments,
{
ContentBytes: Value,
Name: Name
}
),
ForAll(
Attachment_Sitephoto_3.Attachments,
{
ContentBytes: Value,
Name: Name
}
)
)
}
);
Both should work fine.