cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
7thFloor
Level: Powered On

How to add a collection to an email in powerapps

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: How to add a collection to an email in powerapps

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,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

9 REPLIES 9
WarrenBelz
Level 8

Re: How to add a collection to an email in powerapps

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
Level: Powered On

Re: How to add a collection to an email in powerapps

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
Level 8

Re: How to add a collection to an email in powerapps

 @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.

 

Community Support Team
Community Support Team

Re: How to add a collection to an email in powerapps

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,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
7thFloor
Level: Powered On

Re: How to add a collection to an email in powerapps

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
Level: Powered On

Re: How to add a collection to an email in powerapps

 

 

 

 

 

 

WarrenBelz
Level 8

Re: How to add a collection to an email in powerapps

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
Level: Powered On

Re: How to add a collection to an email in powerapps

Warren Belz:

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

 

Thank you!

 

7thFloor

Community Support Team
Community Support Team

Re: How to add a collection to an email in powerapps

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,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Join THE global Microsoft Power Platform event series

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Microsoft Business Applications Virtual Launch

Join us for the Microsoft Business Applications Virtual Launch Event on Thursday, April 2, 2020, at 8:00 AM PST.

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (4,381)