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

SendMail - Group collection and format

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³
1 ACCEPTED SOLUTION

Accepted Solutions
Dual Super User
Dual Super User

Re: SendMail - Group collection and format

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!

View solution in original post

5 REPLIES 5
Community Support Team
Community Support Team

Re: SendMail - Group collection and format

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,

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

Re: SendMail - Group collection and format

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

Dual Super User
Dual Super User

Re: SendMail - Group collection and format

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!

View solution in original post

sanderson82
Level: Powered On

Re: SendMail - Group collection and format

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

Re: SendMail - Group collection and format

@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³")

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

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

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 332 members 5,741 guests
Please welcome our newest community members: