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 / How to add a collectio...
Power Apps
Unanswered

How to add a collection to an email in powerapps

(0) ShareShare
ReportReport
Posted on by 25

I have a canvas app that gathers data from the user via inputs, sliders, checkboxes, etc.

I have a button that creates the collection and labels it "PermitInfo".

The collection input is a toggle with OnChange 

 

Collect(PermitInfo, {NearestHwy: 'NH.inp'.Text, NHState: 'NH-state.ckb'.Text, NHState: 'NH-fed.ckb'.Text, NHLat: 'NH-Lat.inp'.Text, NHLong: 'NH-Long.inp'.Text, POBLat: 'POB-Lat.inp'.Text, POBLong: 'POB-Long.inp'.Text, WorkDescription: 'Work-Desc.inp'.Text, Parish: 'Parish.combo'.Text, ParaHwyNum: 'Para-Hwytxt.inp'.Text, CrossHwyNum: 'Cross-Hwytxt.inp'.Text, Parastate: 'Para-state.ckb'.Text, Parafed: 'Para-fed.ckb'.Text, Crossstate: 'Cross-state.ckb'.Text, Crossfed: 'Cross-fed.ckb'.Text, ParaMainlength: 'Para-Mainlength.inp'.Text, CrossMainlength: 'Cross-Mainlength.inp'.Text, ParaPipeseize: 'Para-Pipesize.sli'.Text, CrossPipesize: 'Cross-Pipesize.sli'.Text, ParaHeyROW: 'Para-HwyROW.inp'.Text, CrossHwyROW: 'Cross-HwyROW.inp'.Text})

 

The collection works. Once they slide the toggle on, it creates the colelction, and makes the email button visible. I can't get the email to send the collection called PermitInfo.

Using:

'Outlook.com'.SendEmail("emailaddress@company.com", Concat(PermitInfo))

 

Any help is appreciated.

 

7thFloor

 

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

    Hi @7thFloor ,

    You need to specify the fields of the collection being "concatted" - so (not sure how wide this will be but you will get the idea)
    You can also do some very good HTML table code with headers to make this look professional.

    Concat(
     PermitInfo, 
     NearestHwy & " " &
     NHState & " " &
     NHLat & " " &
     NHLong & " " &
     POBLat & " " &
     POBLong & " " &
     WorkDescription & " " &
     Parish & " " &
     ParaHwyNum & " " &
     CrossHwyNum & " " &
     Parastate & " " &
     Parafed & " " &
     Crossstate & " " &
     Crossfed & " " &
     ParaMainlength & " " &
     CrossMainlength & " " &
     ParaPipeseize & " " &
     CrossPipesize & " " &
     ParaHeyROW & " " &
     CrossHwyROW
    )

     

    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.

     

  • 7thFloor Profile Picture
    25 on at

    I tried that with just one input to see if it would work. 'Outlook.com'.SendEmail("emailaddress@company.com", "New Permit Request", Concat(PermitInfo, NearestHwy & "NH.inp"))

     

    I got the email, but no information in the body.

     

    If I understand correctly, it should have given me a body of:

    NearestHwy "whatever the number I entered into that text input".

     

    I do appreciate the look of yours to mine. I'm just starting out, so all suggestions are welcome.

     

    Thanks.

     

     

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

     @7thFloor ,

    I always use HTML so there may be a glitch there however the code below works and puts all the items into a table. You will need to modify the column numbers, names and widths, but I am sure you will get the idea. Please put this into a HTML text box and you will see the result immediately without have to send the mail. You can actually then send the YourBoxName.HTMLText as your email body. I have cut this out of a bigger form, but I am sure you will get the idea.

    "<table>
     <tr bgcolor =#D9E1F2>
     <td style='width: 150px'><b>Crew</b></td>
     <td style='width: 80px', align='right'><b>Start</b></td>
     <td style='width: 80px', align='right'><b>Finish</b></td>
     <td style='width: 80px', align='right'><b>Time</b></td>
     <td style='width: 60px', align='center'><b>Travel</b></td>
     <td style='width: 100px;'><b>Vehicle</b></td>
     <td style='width: 80px', align='right'><b>Start</b></td>
     <td style='width: 80px', align='right'><b>Finish</b></td>
     <td style='width: 80px', align='right'><b>Time</b></td>
     <td style='width: 60px', align='center'><b>LAFHA</b></td>
     </tr>
    </table>
    <table>" &
    Concat
    (
    CrewEmail,"
     <tr>
     <td style='width: 150px;'>"&'Crew Name'.Value&"</td>
     <td style='width: 80px', align='right'>"&Text(Start,"[$-en-US]hh:mm")&"</td>
     <td style='width: 80px', align='right'>"&Text(Finish,"[$-en-US]hh:mm")&"</td>
     <td style='width: 80px', align='right'>"&Text(Worked*1,"[$-en-US]#.00")&"</td>
     <td style='width: 60px', align='center'>"&Text(Travel)&"</td>
     <td style='width: 100px;'>"&'Reg No'.Value&"</td>
     <td style='width: 80px', align='right'>"&Text('Plant Start',"[$-en-US]hh:mm")&"</td>
     <td style='width: 80px', align='right'>"&Text('Plant Finish',"[$-en-US]hh:mm")&"</td>
     <td style='width: 80px', align='right'>"&Text('Plant Hours'*1,"[$-en-US]#.00")&"</td>
     <td style='width: 60px', align='center'>"&Text(LAFHAFlag)&"</td>
     </tr>
     <tr>
     <td Colspan='5'>"&'Crew Role'.Value&"
     <td Colspan='5'>"&'Plant Item'.Value&"
     </tr>"
    ) &"
    </Table>"

     

    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 @7thFloor ,

    Do you want to send an email with a collection?
    Actually, the key problem is how to write the collection data in html text and make the data looks like a table.

    The syntax of sending email with html text is:

    Office365.SendEmail(to email address, email subject, HtmlTextEmail.HtmlText, {IsHtml: true})

     You could set HtmlTextEmail's HtmlText like this:   (HtmlTextEmail is a HtmlText1= control)

    "<h3>PermitInfo</h3>" &
    "<strong> Items: </strong>" &
    "<table width='100%' border='1' cellpadding='5' style='border:1px solid black; border-collapse:collapse'>" &
     "<tr style='background-color:#efefef'>
     <th>NearestHwy</th> <th> NHState </th> <th> NHLat </th><th> NHLong </th>
     <th>fieldname</th> ..... 
     </tr>
     <tr>" &
     Concat(PermitInfo,
     "<td>" & NearestHwy & " </td>
     <td>" & NHState & " </td>
     <td>" & NHLat & " </td>
     <td>" & NHLong & " </td>"
     <td>" & fieldname & " </td>"
     ........,
     "</tr><tr>") &
    "</table>"

    Please fill in other fieldnames.

    You could also combine two formulas together:

    Office365.SendEmail(to email address, email subject, 
    "<h3>PermitInfo</h3>" &
    "<strong> Items: </strong>" &
    "<table width='100%' border='1' cellpadding='5' style='border:1px solid black; border-collapse:collapse'>" &
     "<tr style='background-color:#efefef'>
     <th>NearestHwy</th> <th> NHState </th> <th> NHLat </th><th> NHLong </th>
     <th>fieldname</th> ..... 
     </tr>
     <tr>" &
     Concat(PermitInfo,
     "<td>" & NearestHwy & " </td>
     <td>" & NHState & " </td>
     <td>" & NHLat & " </td>
     <td>" & NHLong & " </td>"
     <td>" & fieldname & " </td>"
     ........,
     "</tr><tr>") &
    "</table>", 
    {IsHtml: true})

    Here are docs about how to write html text based on collection data for your reference:

    https://powerusers.microsoft.com/t5/Building-Power-Apps/Data-Table-to-Email-in-PowerApps/m-p/182115

    https://powerapps.microsoft.com/en-us/blog/html-email-reporting-with-tabular-data/

     

     

     

    Best regards,

  • 7thFloor Profile Picture
    25 on at

    Warren Belz:

     

    I do understand basic html coding, and I've tried to apply this to my app's circumstances, but it doesn't even send an email. I'm sure the fault is with me, but here's a thumbs up for trying 😄

     

    Best regards,

     

    7thFloor

  • 7thFloor Profile Picture
    25 on at

     

     

     

     

     

     

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

    Hi @7thFloor ,

    As you can understand I have no idea on your skill set when responding.

    Now that I know you can do HTML, have you tried putting the code in a HTML text box, getting the result you need there and then sending the complete HTML text box as the body of the email. That is how I do all of mine and they always work. So

    "<table>
     <tr bgcolor =#D9E1F2>
     <td style='width: 80px'><b>Nearest Highway</b></td>
     <td style='width: 80px'><b>NH State</b></td>
     <td style='width: 80px'><b>NH Latitude</b></td>
     <td style='width: 80px'><b>NH Longitude</b></td>
     <td style='width: 80px'><b>Prob latitude</b></td>
     <td style='width: 80px'><b>Prob Longitude</b></td>
     <td style='width: 80px'><b>Work Desc</b></td>
     <td style='width: 80px'><b>Parish</b></td>
     <td style='width: 80px'><b>Highway No</b></td>
     <td style='width: 80px'><b>Cross Highway</b></td>
     </tr>
    </table>
    <table>" &
    Concat
    (
    PermitInfo,"
     <tr>
     <td style='width: 80px'>" & NearestHwy & "</td>
     <td style='width: 80px'>" & NHState & "</td>
     <td style='width: 80px'>" & NHLat & "</td>
     <td style='width: 80px'>" & NHLong & "</td>
     <td style='width: 80px'>" & ProbLat & "</td>
     <td style='width: 80px'>" & ProbLong & "</td>
     <td style='width: 80px'>" & WorkDescription &"</td>
     <td style='width: 80px'>" & Parish & "</td>
     <td style='width: 80px'>" & ParaHwyNum & "</td>
     <td style='width: 80px'>" & CrossHwyNum & "</td>
     </tr>"
    ) &"
    </Table>"

    should get you the first ten items in a table in the HTML box. Try sending this (BoxName.HTMLText) as the email body instead of your code.

     

    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.

  • 7thFloor Profile Picture
    25 on at

    Warren Belz:

    That does make sense. I will try this when I get home.

     

    Thank you!

     

    7thFloor

  • Verified answer
    v-yutliu-msft Profile Picture
    on at

    Hi @7thFloor ,

    Actually, the key point of your issue is how to write collection in the format of html text.

    Firstly, you need to create the collection with the data that you want:

    Collect(PermitInfo, {NearestHwy: 'NH.inp'.Text, NHState: 'NH-state.ckb'.Text, NHState: 'NH-fed.ckb'.Text, NHLat: 'NH-Lat.inp'.Text, NHLong: 'NH-Long.inp'.Text, POBLat: 'POB-Lat.inp'.Text, POBLong: 'POB-Long.inp'.Text, WorkDescription: 'Work-Desc.inp'.Text, Parish: 'Parish.combo'.Text, ParaHwyNum: 'Para-Hwytxt.inp'.Text, CrossHwyNum: 'Cross-Hwytxt.inp'.Text, Parastate: 'Para-state.ckb'.Text, Parafed: 'Para-fed.ckb'.Text, Crossstate: 'Cross-state.ckb'.Text, Crossfed: 'Cross-fed.ckb'.Text, ParaMainlength: 'Para-Mainlength.inp'.Text, CrossMainlength: 'Cross-Mainlength.inp'.Text, ParaPipeseize: 'Para-Pipesize.sli'.Text, CrossPipesize: 'Cross-Pipesize.sli'.Text, ParaHeyROW: 'Para-HwyROW.inp'.Text, CrossHwyROW: 'Cross-HwyROW.inp'.Text})

    Your collection is named  PermitInfo and have these fields: NearestHwy,NHState,NHLat,NHLong,POBLat,POBLong ,WorkDescription,Parish ,ParaHwyNum ,CrossHwyNum,Parastate,Parafed ,Crossstate ,Crossfed ,ParaMainlength,CrossMainlength,ParaPipeseize,CrossPipesize ,ParaHeyROW ,CrossHwyROW.

    I suggest you use a HtmlText control to write the html text and use the HtmlText control data directly in your email.

    Set your HtmlText's HtmlText:  (I assume that the HtmlText control named HtmlText1)

    "<h3>PermitInfo</h3>" &
    "<strong> Items: </strong>" &
    "<table width='100%' border='1' cellpadding='5' style='border:1px solid black; border-collapse:collapse'>" &
     "<tr style='background-color:#efefef'>
     <th>NearestHwy</th> <th> NHState </th> <th> NHLat </th><th> NHLong 
     </th<th>POBLat</th> <th>POBLong </th> <th>WorkDescription</th> <th>Parish</th> 
     <th>ParaHwyNum </th> <th>CrossHwyNum</th> <th>Parastate</th> <th>Parafed </th> 
     <th>Crossstate </th> <th>Crossfed </th> <th>ParaMainlength</th> 
     <th>CrossMainlength</th> <th>ParaPipeseize</th> <th>CrossPipesize </th> 
     <th>ParaHeyROW </th> <th>CrossHwyROW</tr>
     //fill in fieldname in this format: <th>fieldname</tr>
     </tr>
     <tr>" &
     Concat(PermitInfo,
     "<td>" & NearestHwy & " </td>
     <td>" & NHState & " </td>
     <td>" & NHLat & " </td>
     <td>" & NHLong & " </td>"
     <td>" & fieldname & " </td>"
     <td>" & POBLat & " </td>"
     <td>" & POBLong & " </td>"
     <td>" & WorkDescription & " </td>"
     <td>" & Parish & " </td>"
     <td>" & ParaHwyNum & " </td>"
     <td>" & CrossHwyNum & " </td>"
     <td>" & Parastate< & " </td>"
     <td>" & Parafed & " </td>"
     <td>" & Crossstate & " </td>"
     <td>" & Crossfed & " </td>"
     <td>" & ParaMainlength & " </td>"
     <td>" & CrossMainlength & " </td>"
     <td>" & ParaPipeseiz & " </td>"
     <td>" & CrossPipesize & " </td>"
     <td>" & ParaHeyROW & " </td>"
     <td>" & CrossHwyROW<& " </td>", 
     //fill in fieldname in this format: <td>" & fieldname<& " </td>"
     "</tr><tr>") &
    "</table>"
    
    

     Then send email with this html text:

    Office365.SendEmail(to email address, email subject, HtmlText1.HtmlText, {IsHtml: true})

     

     

    Best regards,

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

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard