Hi Zhi,
My take on Shane's process (which I currently use a variation of) is for saving pen input in SharePoint where the data is an image in PowerApps.
Set(vImage,JSON(MyPenInput.Image,JSONFormat.IncludeBinaryData));Set(vImage,Mid(vImage,24,Len(vImage) - 24))produces a Base64 string, then in the PowerAutomate file content
base64ToBinary(triggerBody()['Createfile_FileContent']) sends it to SharePoint.
As you have noted, you have collected the data and displayed it. I am no expert on this, but as you know, Image controls will display a number of formats and Shane's code referred to
.Image properties in the object being converted.
This post may be useful to you to get the content another way, but I have not tried it. Also note (as below) dataUri format works in HTML embedded images.
This may be helpful (or not), but I use a different process emailing signed forms (with the Pen Input), which are saved as JPGs in a SharePoint Library, so the principle is the same as your requirements.
The process only sends the HTML body and file URL/s from PowerApps but has a fairly large Power Automate process (which I have attached) and will briefly run you though it (it also attaches the PDF to an email).
MyPhotoFlow.Run( Image1_Path/Name, Image2_Path/Name, HTMLContent.HtmlText, FileName, SharePoint_Metadata1, SharePoint_Metadata2,EmailAddressToSendTo, EmailSubject, EmailBody );Firstly, note this is a test version where SharePoint and Email was added later, so you do not need the
Delete OneDrive PDF, but the
Create OneDrive PDF is needed if getting the file from there. The sequence for SharePoint email is:
- Get the content of the Image/s from the SP Library.
- Get the HTML Text in a Variable.
- Get the File Name (useful in a Variable as two different extensions are used later on).
- Convert image content to dataUri.
- Use an Expression to concat the HTML text Variable with the bit containing the images (a HTML table used with content below).
- Convert the HTML output to PDF.
- Create OneDrive PDF (if not using SharePoint).
The following I also do: -
- Copy PDF to SharePoint with Metadata.
- Delete the SharePoint HTML file.
- Attach SharePoint PDF file to an email.
As noted above the HTML Expression in mine (to put two signatures in a table) is (you only need the bold bits for yours): -
concat(variables('HTMLPage'),'<table border="0" cellspacing="0" cellpadding="0"><tbody><tr><td width="250"><strong>Signature of Owner/Occupier</strong></td><td width="250"><strong>Ergon Signature</strong></td></tr><tr><td width="250"><img src="',variables('OwnerImg'),'" alt="Owner Signature" height="40" width="200"></td><td width="250"><img src="',variables('VentiaImg'),'" alt="Ergon Signature" height="40" width="200"></td></tr></tbody></table>')
One thing to watch (as you would know) the HTML body text in PowerApps is surrounded by double quotes " with single quotes ' in the HTML. The concat in the expression is the opposite - concatenated parts are separated by single quotes with double quotes in the HTML, so
"',variables('VentiaImg'),'" above is double-single at the start and single-double at the end. Fortunately HTML renders either as quotes.
I hope this is useful
------------------------------
Warren Belz
Ventia Utility Services Pty Ltd
Rockhampton Qld Australia
+61 409 315 509
------------------------------
Original Message:
Sent: Jan 03, 2020 12:02 AM
From: Zhi Rui Foo
Subject: Embed Sharepoint List Photo Attachments to HTML/PDF and Email to End User
Hi All,
Hope someone can assist with the following.
I have an app that puts together a HTML report based on data drawn from several Sharepoint lists. There is one component that has stumped me, which is getting the photo attachments out of one Sharepoint list and putting them at the end of the HTML report.
I wanted to use the json trick shared by Shane Young (https://www.youtube.com/watch?v=RFZfvTuDmP0&list=PLCGGtLsUjhm2bonhBZuEhZU72QkFjOpc6&index=71) to turn the attachments into base64 so that they can be embedded into the HTML, but this does not appear to work (or I am missing a step).
The Sharepoint list photo attachments follow the format "appres://datasources/..." when copied to a local collection on the app I made, and I can display them properly in the App using the image control.
When I try to apply the above value through Set(globalVar,JSON(<value>)), the format doesn't change to base64 as expected (it remains as appres). Since the conversion doesn't work I just end up with broken images at the end of the HTML report due to the code "<img src="&globalVar&" style='width:100%;height:100%;'>".
Anyone have any insight for this? Either something additive to the steps outlined above or an alternative strategy would be greatly appreciated.
------------------------------
Zhi Rui Foo
Operations Development Executive
+65 6483 3335
------------------------------