cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
garethaw
Helper III
Helper III

edit the body of an email

Hi,

 

I'm trying to edit the html body of an email.

 

I want to replace some text within the body, do I need to convert the email body to text before this can be done?

 

Thanks

12 REPLIES 12
Anonymous_Hippo
Super User
Super User

Hello @garethaw 

 

You do not need to convert back. Both works !!!! You can edit as HTML or covert back to text edit and then convert to HTML again

Great, are you able to point me in the right direction. I've got the contents of the email. I want to replace some text "75-100%" with "91%" ?

VictorIvanidze
Community Champion
Community Champion

Use replace() function.

--------------------------------------------------------------------------------------
Contact me if you are interested in custom Power Automate development.

I've tried using the replace expression but it says in the input is of type of object?

VictorIvanidze
Community Champion
Community Champion

Please show your replace.

--------------------------------------------------------------------------------------
Contact me if you are interested in custom Power Automate development.
garethaw
Helper III
Helper III

replace(body('Email'), '75%-100%', '91%')

 

garethaw_0-1651570703964.png

 

VictorIvanidze
Community Champion
Community Champion

What's your second block - "Get email (V2)" or "Get emails (V3)"?

--------------------------------------------------------------------------------------
Contact me if you are interested in custom Power Automate development.

v3

VictorIvanidze
Community Champion
Community Champion

Click "Show raw output" in "Get emails (V3)".

You'll see something like this. Note that "body" contains array "value". Each element of this array represents a message. 

 

 "statusCode": 200,
    "headers": {
        "Pragma": "no-cache",
        "Transfer-Encoding": "chunked",
        ...
        "Expires": "-1",
        "Content-Length": "33628"
    },
    "body": {
        "value": [
            {
                "id": "AAMkAGQ4YTA4OWNiLTQzMDQtNDQ1YS05YWI1LWVkM2M0NTU2ZWIyYQBGAAAAAAAeFskUmM3QT6bXbUpoyma4BwAzka6HX-3hR5u7st8nEUz8AAAAAAEMAAAzka6HX-3hR5u7st8nEUz8AAMKTIVIAAA=",
                ...

 

 

--------------------------------------------------------------------------------------
Contact me if you are interested in custom Power Automate development.
CopeStarr
Helper I
Helper I

Here's a link that shows how to create the email in Outlook and copy the code into PowerAutomate, without the need to code it all: https://davidlozzi.com/2018/11/01/sending-a-beautifully-formatted-email-from-microsoft-flow/#respond 

{
    "statusCode"200,
    "headers": {
        "Pragma""no-cache",
        "Transfer-Encoding""chunked",
        "Vary""Accept-Encoding",
        "x-ms-request-id""f7f6c463-ac05-4f69-82c9-c467f5e31443;92157939-d275-4ad7-915a-1f21847b2231;1b07e65b-9785-4d27-8f2e-9f64c5207493;a4c7fa3a-841f-4398-8ab4-4de8fd840253;3f567118-0791-4cd3-b61d-a6465ca0d837",
        "Strict-Transport-Security""max-age=31536000; includeSubDomains",
        "X-Content-Type-Options""nosniff",
        "X-Frame-Options""DENY",
        "Cache-Control""no-store, no-cache",
        "Set-Cookie""ARRAffinity=ddcb58f4e7d4612fd9d0aff3394b5e86024fefcfe9489e80129e4b872a8b7da9;Path=/;HttpOnly;Secure;Domain=office365-ne.azconn-ne-002.p.azurewebsites.net,ARRAffinitySameSite=ddcb58f4e7d4612fd9d0aff3394b5e86024fefcfe9489e80129e4b872a8b7da9;Path=/;HttpOnly;SameSite=None;Secure;Domain=office365-ne.azconn-ne-002.p.azurewebsites.net",
        "Timing-Allow-Origin""*",
        "x-ms-apihub-cached-response""false",
        "x-ms-apihub-obo""true",
        "Date""Tue, 03 May 2022 10:50:52 GMT",
        "Content-Type""application/json; charset=utf-8",
        "Expires""-1",
        "Content-Length""12"
    },
    "body": {
        "value": []
    }
}
VictorIvanidze
Community Champion
Community Champion

The "value" is an empty array. It means there are no emails have been retrieved.

You should check if the value is empty before trying to replace.

--------------------------------------------------------------------------------------
Contact me if you are interested in custom Power Automate development.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

Top Solution Authors
Users online (1,859)