Using an If() statement, I'm trying to send emails which may or may not have attachments but it keeps telling me the attachments datacard cannot be null or empty:
Error:
Code:
If(CountRows(DataCardValue44.Attachments)=0,
[then] Office365.SendEmail(myEmailAddress, "HTML & attachment", HTMLPOBEmail_1.HtmlText,{IsHtml: true}),
[else] Office365.SendEmail(myEmailAddress, "HTML & attachment", HTMLPOBEmail_1.HtmlText,{Attachments:Table({Name:"Septic Log", ContentBytes:First(DataCardValue44.Attachments).Value, '@odata.type':"" }), IsHtml: true}))
So, if the datacard has no attachment it fails, even though I've used an IF(). I thought the If() would stop at THEN but it appears to also check the ELSE for errors? I can use either the THEN or ELSE code as separate calls and they work fine it's just when they are bundle together they fail.
Note: The ELSE statement will fail if there is no attachments but works if there is...
Do I need to Remove then re-add back the O365 connector? If so, would this harm my App? This App is currently in use and emails are being used for other functions. This is just an extension of these functions.
Any help would be greatly appreciated.

Report
All responses (
Answers (