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 / SendMail - Group colle...
Power Apps
Unanswered

SendMail - Group collection and format

(0) ShareShare
ReportReport
Posted on by 97

Hi

I have the following code to send an e-mail for a collection from my app

Office365.SendEmail(
 "email address",
 "Daily Production - " & I_Date.SelectedDate,
 Concat(
 DailyProd,
 Title & Char(10) & Qty & " No " & Unit & " , " & Volume & "m³" & Char(10) & Char(10)
 ) &
 "Total Units : " & Sum(DailyProd,Qty) & Char(10) &
 "Total Volume : " & Sum(DailyProd,Volume) & "m³")

This gives an output like below....

C3618 - KIRKCALDY
1 No Unit A , 0.5m³

C3618 - KIRKCALDY
1 No Unit B , 0.67m³

C3615 - THANCKES CULVERT
1 No Culvert 1A , 2.658m³

C3600 - DUNBAR SLABS
4 No Slab , 0.79m³

C3603 - AFC WIMBLEDON
1 No A2 , 1.08m³

Total Units : 8
Total Volume : 5.698m³

Is it possible to summarise or GroupBy the title (and bold it) to give an output like below?

C3618 - KIRKCALDY
1 No Unit A, 0.5m³
1 No Unit B, 0.67m³

C3615 - THANCKES CULVERT
1 No Culvert 1A, 2.658m³

C3600 - DUNBAR SLABS
4 No Slab, 0.79m³
Categories:
I have the same question (0)
  • v-yutliu-msft Profile Picture
    on at

    Hi @sanderson82 ,

    Firstly, if you want to use groupby function, you need to format the data to a table.

    While the code that you use:

     Concat(
     DailyProd,
     Title & Char(10) & Qty & " No " & Unit & " , " & Volume & "m³" & Char(10) & Char(10)
     ) &
     "Total Units : " & Sum(DailyProd,Qty) & Char(10) &
     "Total Volume : " & Sum(DailyProd,Volume) & "m³")

     will result a text.

    Secondly , if you want to bold the title, this could work.

    You just need to wrap the text you want bolded in bold tags, like so: <b> boldedText </b>

    Here's a blog about how to format your text to html text for your reference:

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

     

     

    Best regards,

  • sanderson82 Profile Picture
    97 on at

    Hi @v-yutliu-msft   the following code helped me to achieve what I needed, using GroupBy to create a second collection (Prod2)

    ClearCollect(Prod2,
     GroupBy(DailyProd,"Title","Contracts"));
    Office365.SendEmail(
     "email address",
     "Daily Production - " & I_Date.SelectedDate,
     Concat(
     Prod2,
     Char(10) & Title & Char(10) &
     Concat(
     Contracts,
     Qty & " No " & Unit & " , " & Volume & "m³" & Char(10)
     ) 
    ) & Char(10) &
     "Total Units : " & Sum(DailyProd,Qty) & Char(10) &
     "Total Volume : " & Sum(DailyProd,Volume) & "m³")

    However if I amend Title with <b>Title</b> in the above code I get an error

  • Verified answer
    yashag2255 Profile Picture
    24,769 Super User 2024 Season 1 on at

    Hi @sanderson82 

     

    Can you try to update your expression as:
    ClearCollect(Prod2,
        GroupBy(DailyProd,"Title","Contracts"));
    Office365.SendEmailV2(
        "email address",
        "Daily Production - " & I_Date.SelectedDate,
        Concat(
            Prod2,
            Char(10) & "<b>"&Title&"</b>" & Char(10) &
            Concat(
                Contracts,
                Qty & " No " & Unit & " , " & Volume & "m³" & Char(10)
        )
    ) & Char(10) &
        "Total Units : " & Sum(DailyProd,Qty) & Char(10) &
        "Total Volume : " & Sum(DailyProd,Volume) & "m³")
     
    Make sure you are using SendEmailV2 action to allow HTML text inside the body.
     
    Hope this Helps!

    If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
  • sanderson82 Profile Picture
    97 on at

    Hi @yashag2255   That worked in terms of the Title being bold however it has knocked off my other formatting, i.e. it is all in one line now

     

    C3618 - KIRKCALDY 1 No UNIT A , 0.235m³ C3603 - AFC WIMBLEDON 1 No A2 , 1.08m³ Total Units : 2 Total Volume : 1.315m³

     

    Can I assume this is due to the email now being in HTML format?  Do I replace Char(10) with line breaks?

  • sanderson82 Profile Picture
    97 on at

    @yashag2255  this is now working replacing Char(10) with <br>.   Thankyou!

    ClearCollect(Prod2,
     GroupBy(DailyProd,"Title","Contracts"));
    Office365.SendEmailV2(
     "email address",
     "Daily Production - " & I_Date.SelectedDate,
     Concat(
     Prod2,
     "<br>" & "<b>"&Title&"</b>" & "<br>" &
     Concat(
     Contracts,
     Qty & " No " & Unit & " , " & Volume & "m³" & "<br>"
     ) 
    ) & "<br>" &
     "Total Units : " & Sum(DailyProd,Qty) & "<br>" & 
     "Total Volume : " & Sum(DailyProd,Volume) & "m³")

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