web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / convert HTML to word a...
Power Apps
Answered

convert HTML to word attachment

(0) ShareShare
ReportReport
Posted on by 115

Hi, i have a button able to send the collection data to email

ffice365Outlook.SendEmail("email","Test222",Concatenate("<table style=""width:100%"" border=""1"">
<tr>
<th>BBB</th>
<th>Finding</th>
<th>Rectification</th>
</tr>",Concat(ForAll(FilteredCollection,"
<tr>
<td>"&ThisRecord.No&"</td>
"&"<td>"&Concat(Filter(ForAll(ThisRecord.image,If("before" in ThisRecord.DisplayName,"<img height=""100"" width =""100"" src='"&ThisRecord.AbsoluteUri&"'>")),!IsBlank(Value)),Value)&"</td>"&"<td>"&Concat(Filter(ForAll(ThisRecord.image,If("after" in ThisRecord.DisplayName,"<img height=""100"" width =""100"" src='"&ThisRecord.AbsoluteUri&"'>")),!IsBlank(Value)),Value)&"</td>"&"
</tr>
"),Value),"</table>"),{IsHtml: true })

Email Received

pityman_0-1616001713958.png

Now the question is, is it possible to convert it to a word file? Meaning that when i click on the button, i will be able to see the table in the email as well as the word attachment which also consist of the table ?

Thank you

 

Categories:
I have the same question (0)
  • Pstork1 Profile Picture
    68,717 Most Valuable Professional on at

    Shane Young has a great video on creating PDFs from HTML. But the convert action he uses can also output to Word format.  So yes the HTML table can be converted to a Word document and then attached to the email using Power Automate.

    PowerApps PDF Generator using Microsoft Flow PDF Converter - Bing video

  • pityman Profile Picture
    115 on at

    Hi@Pstork1, i tried to follow the video and the images gone. any idea?

    pityman_0-1616039613470.png

     

  • Pstork1 Profile Picture
    68,717 Most Valuable Professional on at

    As Shane explained in the video you need to convert the images to files and then insert the contents of the files into the HTML.  You can't just reference the images by URL. You have to get the file content, process it with the dataUri() function and insert the resulting string into the HTML.  Shane does this with a variable at around the 10 minute mark of the video. If you are doing multiple images you can do it with either a variable or a Compose.

  • pityman Profile Picture
    115 on at

    HI @Pstork1 , yes, there are no issues when get the specific image in sharepoint/one drive and convert into 64images.

    Currently my problem is,

    the images are in a collection. How do i get the content of the images from a collection in powerapps and , process them with the dataUri() function?

  • Pstork1 Profile Picture
    68,717 Most Valuable Professional on at

    By Collection I assume you mean an array.  If so you would use an Apply to Each loop to loop through the array, retrieve each image and save it to HTML using the dataUri() function.  Inside each loop you would add all the entries to the HTML table for that Row.

  • pityman Profile Picture
    115 on at

    @Pstork1 

    i am really appreciate if you can show me the example 

  • Verified answer
    Pstork1 Profile Picture
    68,717 Most Valuable Professional on at

    Here is an example. I created an app that has a small collection called 'myData' containing the path to an image in onedrive, the relative path to the image, and the name of the file. 

    image.png

    When you press the button it invokes a flow and passes the collection to the flow as a JSON array using the following 

    HTML2PDF.Run(JSON(myData,JSONFormat.Compact))

     The flow then processes the collection.  Here are screenshots of the flow.

    The array is passed in as the only parameter and processed using a Parse JSON action

    image.png

    I then create two string Variables, one to hold the top of the HTML file and one to hold the bottom.

    image.png

    Next I create a loop to process the JSON array loaded earlier.  Inside the loop I use the relative path to retrieve the image contents, A compose to translate the contents to DataURI encoding, and then append the converted image and name to the header string variable as an HTML row.  The loop processes each image.

    image.png

    once the loop exits I append the html footer variable to close out the HTML.  Then I save the HTML file to OneDrive, Convert it to PDF, and then save the Converted file.  (Encodian has a conversion option that can convert from HTML to Word).

    image.png

    Here's what the finished file looks like.

    image.png

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard