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 Apps
Unanswered

email send help

(0) ShareShare
ReportReport
Posted on by 98

Hello,

 

I have an app which has a screen with Html text to concat a table from data tables within the app and this all works fine.

 

There is a button configure to email the table and display in the body of the email using the string below- There is an intermittent issue where upon pressing the button to send an email it will display the default Html text 'Show your HTML text here' even though there is no reference to this text in the html code. If I press the button again it sends the tables and display fine.

 

I have tried removing the screen and adding again to no avail. Is there a way I can add the output of the table as an attachment rather than the body without using flows or has anyone got any suggestion as to what the issue could be?

 

Office365Outlook.SendEmailV2("email address,"My Car Stock",HtmlText1.HtmlText)

 

Any help would be much appreciated.

 

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    153,030 Most Valuable Professional on at

    Hi @dandandsan ,

     I send hundreds of emails using the exact syntax you use and have had no issues, so have you had a look at the absolute validity of your HTML code. I mention this as the HTML text box in PowerApps is rather "forgiving" on small code errors, particularly closing tags. I have found this particularly on your second question as I also send PDF attachments of HTML code and it has to be "spot on" for OneDrive to convert it.

    On that question - here is a good video from Shane Young @Shanescows that runs you through the process.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • v-yutliu-msft Profile Picture
    on at

    Hi @dandandsan ï¼Œ

    Do you want to send email with an attachment that data is html text by not using flow?
    Firstly, if you only use powerapps, I'm afraid it's not supported to generate an attachment from html text and send it in email.

    Powerapps does not support the function of generating attachments.

    Actually, I do not know why you want to convert html text to an attachment.

    You could directly send email that body is the html text directly.

    Try this formula:

    Office365Outlook.SendEmailV2("email address,"My Car Stock",HtmlText1.HtmlText,{IsHtml:true})

    Then email body will display in html format.

     

    Secondly, if you insist in sending email with attachments, then you need to use flow to generate the attachment.

    After you generate an attachment, you could use this formula to send email with attachment:

    Office365Outlook.SendEmailV2("email address,"My Car Stock","Attachments", 
    {Attachments:AddColumns(the attchment file, "Name", DisplayName, "ContentBytes", Value, "@odata.type", "")})

     

     

     

    Best regards,

  • dandandsan Profile Picture
    98 on at

    @WarrenBelz @v-yutliu-msft 

     

    Thank you for taking the time to reply.

     

    I had been looking at a way to add an attachment without using flows to try and troubleshoot the email body issue but now I understand the process more I think I will look at my html code as this sound like the most logically culprit. 

     

  • WarrenBelz Profile Picture
    153,030 Most Valuable Professional on at

    OK @dandandsan ,

    That was my thought process as well. I have never bothered adding the {IsHtml:true} on the end as Outlook seems to render this OK without it.

    You can add content such as photos from the camera as attachments without a Flow, but not a piece of HTML text.

    Happy to assist further if required.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • dandandsan Profile Picture
    98 on at

    Appreciate all the help - I've not known a forum like it!

     

    This is a bit cheeky but if you don't ask....what do you think of the following code? 99% of the time it works and doesn't display the default text so not sure where I'm going wrong?

     

    //TABLE 1
    "<h3>Car Stock</h3>" &
    "<strong>TONER</strong>" &
    "<table width='100%' border='1' cellpadding='5' style='border:1px solid black; border-collapse:collapse'>" &
     "<tr style='background-color:#efefef'>
     <th>Description</th>
     <th>Device</th>
     <th>Current Stock</th>
     </tr>" &
     Concat('Toner Stock',
     "<tr>
     <td>" & Description & " </td>
     <td>" & Device & " </td>
     <td>" & 'Current Level' & " </td>
     </tr>") &
     "</table>" &
    //TABLE 2
    "<strong>DRUM</strong>" &
    "<table width='100%' border='1' cellpadding='5' style='border:1px solid black; border-collapse:collapse'>" &
     "<tr style='background-color:#efefef'>
     <th>Description</th>
     <th>Device</th>
     <th>Current Stock</th>
     </tr>" &
     Concat('Drum Stock',
     "<tr>
     <td>" & Description & " </td>
     <td>" & Device & " </td>
     <td>" & 'Current Level' & " </td>
     </tr>") &
     "</table>" &
    //TABLE 3
    "<strong>ROLLER</strong>" &
    "<table width='100%' border='1' cellpadding='5' style='border:1px solid black; border-collapse:collapse'>" &
     "<tr style='background-color:#efefef'>
     <th>Description</th>
     <th>Device</th>
     <th>Current Stock</th>
     </tr>" &
     Concat('Roller Stock',
     "<tr>
     <td>" & Description & " </td>
     <td>" & Device & " </td>
     <td>" & 'Current Level' & " </td>
     </tr>") &
     "</table>" &
    //TABLE 4
    "<strong>CHIP</strong>" &
    "<table width='100%' border='1' cellpadding='5' style='border:1px solid black; border-collapse:collapse'>" &
     "<tr style='background-color:#efefef'>
     <th>Description</th>
     <th>Device</th>
     <th>Current Stock</th>
     </tr>" &
     Concat('Jon Chip Stock',
     "<tr>
     <td>" & Description & " </td>
     <td>" & Device & " </td>
     <td>" & 'Current Level' & " </td>
     </tr>") &
     "</table>" &
    //TABLE 5
    "<strong>FUSER</strong>" &
    "<table width='100%' border='1' cellpadding='5' style='border:1px solid black; border-collapse:collapse'>" &
     "<tr style='background-color:#efefef'>
     <th>Description</th>
     <th>Device</th>
     <th>Current Stock</th>
     </tr>" &
     Concat('Fuser Stock',
     "<tr>
     <td>" & Description & " </td>
     <td>" & Device & " </td>
     <td>" & 'Current Level' & " </td>
     </tr>") &
     "</table>" & //TABLE 6
    "<strong>ITB</strong>" &
    "<table width='100%' border='1' cellpadding='5' style='border:1px solid black; border-collapse:collapse'>" &
     "<tr style='background-color:#efefef'>
     <th>Description</th>
     <th>Device</th>
     <th>Current Stock</th>
     </tr>" &
     Concat('Jon ITB Stock',
     "<tr>
     <td>" & Description & " </td>
     <td>" & Device & " </td>
     <td>" & 'Current Level' & " </td>
     </tr>") &
     "</table>" &
    //TABLE 7
    "<strong>WASTE</strong>" &
    "<table width='100%' border='1' cellpadding='5' style='border:1px solid black; border-collapse:collapse'>" &
     "<tr style='background-color:#efefef'>
     <th>Description</th>
     <th>Device</th>
     <th>Current Stock</th>
     </tr>" &
     Concat('Waste Stock',
     "<tr>
     <td>" & Description & " </td>
     <td>" & Device & " </td>
     <td>" & 'Current Level' & " </td>
     </tr>") &
     "</table>" &
    //TABLE 8
    "<strong>NETWORK</strong>" &
    "<table width='100%' border='1' cellpadding='5' style='border:1px solid black; border-collapse:collapse'>" &
     "<tr style='background-color:#efefef'>
     <th>Description</th>
     <th>Current Stock</th>
     </tr>" &
     Concat('Jon Network Stock',
     "<tr>
     <td>" & Description & " </td>
     <td>" & 'Current Level' & " </td>
     </tr>") &
     "</table>" &
    //TABLE 9
    "<strong>Office Stock</strong>" &
    "<table width='100%' border='1' cellpadding='5' style='border:1px solid black; border-collapse:collapse'>" &
     "<tr style='background-color:#efefef'>
     <th>Description</th>
     <th>Current Stock</th>
     </tr>" &
     Concat('Office',
     "<tr>
     <td>" & Description & " </td>
     <td>" & 'Current Level' & " </td>
     </tr>") &
     "</table>" &
    //TABLE 10
    "<strong>MISC</strong>" &
    "<table width='100%' border='1' cellpadding='5' style='border:1px solid black; border-collapse:collapse'>" &
     "<tr style='background-color:#efefef'>
     <th>Description</th>
     <th>Device</th>
     <th>Current Stock</th>
     </tr>" &
     Concat('Misc Stock',
     "<tr>
     <td>" & Description & " </td>
     <td>" & Device & " </td>
     <td>" & 'Current Level' & " </td>
     </tr>") &
     "</table>"

     

     

  • Verified answer
    WarrenBelz Profile Picture
    153,030 Most Valuable Professional on at

    Hi @dandandsan ,

    Very nice and basic (nothing unnecessary), which I also try to do. You have closed all your tags properly and also indented your code (good to see). I got it working in a HTML Box with dummy collections named after your table names, however the most tables I have ever sent is two.

    On that subject, if you are calling data source tables directly on each Concat call, you are doing it 10 times in rendering this code. This could definitely have the potential to affect reliability. If each list is under 2000 items (or for the ones that are), consider doing a collection

    ClearCollect(
     colTonerStock,
     ShowColumns(
     'Toner Stock',
     "Description",
     "Device",
     "Current Level"
     )
    )

    then in the HTML

    Concat(colTonerStock,
     "<tr>
     <td>" & Description & " </td>
     <td>" & Device & " </td>
     <td>" & 'Current Level' & " </td>
     </tr>")

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • dandandsan Profile Picture
    98 on at

    @WarrenBelz 

     

    Thank you for info, the data source tables are well under 2000 item so keen to explore this option.

     

    Sorry for the silly question but do I put the clear collect string into the data table?

  • WarrenBelz Profile Picture
    153,030 Most Valuable Professional on at

    Hi @dandandsan ,

    No you need to trigger it from something to create the collections. The start of the code on the Send Email button will do the job. You also obviously need to do them all one after the other and if any are over 500 items increase the limit for the app in Advanced Settings.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • v-yutliu-msft Profile Picture
    on at

    Hi @dandandsan ,

    If you do not want to transfer your html text to an attachment, then I suggest you just send email with the html text.

    Since your html data is a little large, I suggest you firstly save it in collection, then use the collection to send email.

    Thanks for the advice that he poseted @WarrenBelz .

    Let me explain the steps that you should do:

    1)create a collection with the data in your data source:

    (set a button's OnSelect or the screen's OnVisible)

    ClearCollect(
     colTonerStock,
     ShowColumns(
     'Toner Stock',
     "Description",
     "Device",
     "Current Level"
     )
    )

    2)set the send email button's OnSelect:

    Office365Outlook.SendEmailV2("email address,
     "My Car Stock",
     Concat(colTonerStock,
     "<tr>
     <td>" & Description & " </td>
     <td>" & Device & " </td>
     <td>" & 'Current Level' & " </td>
     </tr>"
     ),
     {IsHtml:true})

     

     

    Best regards,

  • dandandsan Profile Picture
    98 on at

    @WarrenBelz Once again thank you for all your help.

     

    @v-yutliu-msft  Thank you for the further explanation  - All makes sense now and the collection is the way forward. 

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 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard