Does anyone know if we can use base64 string as input for Powerapps V2 trigger, then 'convert' it to email attachment?
I built a flow to get files from PowerApps, then send it as an email attachment via SMTP. In my app, there are two attachment controls, one is mandatory, another one is optional. Upon submit the request, it triggers a flow, i.e. if both attachment controls contain files, one email will be sent; if not, another email template will be used.
Initially I tried adding two 'file' inputs to PowerApps V2 trigger and mark one of them as optional, but it doesn't like it. So, I ended keeping one 'file' input for the mandatory attachment control. For the second attachment control, if it's used, I converted the attachment to base64 string in the app. Then I used two text inputs to bring in base64 string and 'name'. This allows me keeping the second attachment control as 'optional'.
What I found is: it works when I use PowerApps trigger but not working for PowerApps V2. In fact, it used to work with PowerApps V2 trigger but suddenly stopped working. When using PowerApps V2 trigger, it sends emails but the attachment cannot be opened.
PowerApps trigger doesn't work well as it misses 'mark it optional' function. Does anyone know if there's a trick on this?
I think the problem is when you are passing the file content for the optional field it is being passed in string format and not in base64 because of which the attachments are getting corrupted.
Can you please enclose the word file content in a base64 function to convert the string into base64 and pass it as file content. This should hopefully resolve the issue.
Hi Gopala, in the app, I have converted the file content to a base64-only string, then pass it to the flow.
Without changing the setting on the app or the setting of the SMTP email action, the flow works well when the trigger is "PowerApps". However, once I change it to "PowerApps (V2)", the file is corrupted.
See example in the attached snapshot, the right base64 string is passed to the flow. I did cross-check in the past: the same file is attached via both attachment controls, when checking the SMTP input, exactly the same 'ContentData' 'ContentType' and 'FileName' were used, but one worked, another one corrupted.