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 Automate / Send email from teams ...
Power Automate
Unanswered

Send email from teams channel message (in HTML)

(0) ShareShare
ReportReport
Posted on by 36

Hi Guys, I have a rather simple flow, but I think there are some formatting limitations which prevent it from working

 

I'm using an email building tool (Unlayer) from which I export the full email in raw HTML code.
My plan was to post this raw HTML code into a teams channel and then this would generate an email. 

Technically I've created the flow and it works fine for plain text , etc.
Unfortunately, when I post raw HTML code in teams it doesn't get converted into a nice looking email. 

It sends the email, but I also receive an email with just HTML code.

 

Any ideas how I can convert this and make it work as expected?

 

MVMar_0-1698823567210.png

 

 

I've been using power automate to send HTML emails many times, but apparently there's some formatting issue that occurs when the data is captured from the teams post. 

Categories:
I have the same question (0)
  • v-yueyun-msft Profile Picture
    on at

    Hi , @MVMar 

    I test it in my side , the return from Teams the Html will be differnt like this:

    vyueyunmsft_0-1698824912363.png

    So we need to use the replace() function to replace these String to the right Html code.

    We can use this code to covert the body/content:

    replace(replace(replace(replace(variables('EmailBodyContent'),'&lt;','<') , '&gt;','>'),'&nbsp;',' '),';<br>','')
     
    You can also use a "Compose" action to check if the return contains Invalid HTML characters.Our ultimate goal is to replace the value returned by Teams with a valid Html code using the replace function.
    Then we can use this Html String to send an email .
     

    Best Regards,

    Yueyun Zhang

  • CFernandes Profile Picture
    8,402 Most Valuable Professional on at

    Hey @MVMar - You can try @v-yueyun-msft suggestion 

     

    Another quick tip would be to try "Convert HTML to TEXT" action.

     

    CFernandes_0-1698826300695.png

    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!

     

    P.S. take a look at my blog here and like & subscribe to my YouTube Channel thanks.

     

     

  • MVMar Profile Picture
    36 on at

    Hi, @v-yueyun-msft 
    Thank you for getting back to me so fast. 

    Now I see what you mean. 
    I've compared the input (left) and output (right) and I understand what's wrong. 

     

    MVMar_2-1698828166568.png


    I tried your suggestion with the expression you gave me, but when applied, it completely breaks the HTML code, to the point where it's unusable. I assume there are a other replacements that need to be done in order to clean it enough to the point where it's useable again. 

    In the meantime, I noticed something else - in Teams I can add a code snippet and post that. Is there a way I can extract the clean, unaltered HTML code from that snippet and dump it into the email body?
    I saw that it's added as an "attachment" but no apparent way to get the contents of the attachment.

     

    MVMar_0-1698827780877.png

    MVMar_1-1698827993962.png

     

     

  • v-yueyun-msft Profile Picture
    on at

    Hi, @MVMar 

    Thanks for your quick response! Yes , the "When a new channel message is added" trigger will breaks the html code.As you can see in your screenshot, he converts '<' into '&lt;' in Html, '>' into '&gt;', space into '&nbsp;' and so on. I think we can indeed use the replace() function to re-extract the converted Html code, which is not insecure. 

     

    And as searched , i found no way to extract the code snipped from Teams in Power Automate.

     

    Best Regards,

    Yueyun Zhang

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

    Hi , @MVMar 

    I test it in my side .By another , i also test the Attachments in Teams Channel , i think this can also be realize it.

    vyueyunmsft_0-1698831211626.png

    And this is my txt file:

    vyueyunmsft_2-1698831771686.png

     

    As we can see the trigger return if you upload an attachment:

    vyueyunmsft_1-1698831748350.png

     

    We can get the file content using the "Get file content using path" action.

    vyueyunmsft_3-1698831915161.png

    And we can see the html will not break just has '\r\n' when the txt have a line breaks. We can replace it use this code:

    replace(outputs('Get_file_content_using_path')?['body'],decodeUriComponent('%0D%0A'),'')
    vyueyunmsft_4-1698832024161.png

    For this , you can refer to :
    Solved: Split at \r\n\r\n - Power Platform Community (microsoft.com)

     

    And then we can also get the correct html code to send an email.

     

    Best Regards,

    Yueyun Zhang

  • MVMar Profile Picture
    36 on at

    This way it actually works. 
    I added some additional things to pick up the name, etc. but it works as intended. 
    Thank you! 

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 Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 463 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 427 Moderator

#3
abm abm Profile Picture

abm abm 245 Most Valuable Professional

Last 30 days Overall leaderboard