Skip to main content

Notifications

Power Automate - Building Flows
Answered

Capture Email addresses from an Email body into an array

(0) ShareShare
ReportReport
Posted on by 1,085

I have several email addresses of different domains in an email body. Mainly in To, From and Cc sections. I would like to parse the email body and get all email addresses into an array? Can someone help me with the hint or steps to do it. I am aware of string functions in Power Automate but not sure of how to start with it.

  • Verified answer
    rameshmukka Profile Picture
    rameshmukka 1,085 on at
    Re: Capture Email addresses from an Email body into an array

    @v-yiwenxie-msft Thank you for your time and solution. And sorry for coming late here. I think I haven't framed my question more precisely? Requirement was to get all email addresses from the body of the email. The body can contain a conversation between several people, I was referring email address of all those. I have figured out the solution myself during this time.

     

    Convert Email body to plain text

    RameshMukka_0-1613208441578.png

    Update my planner task description with convert body text

    RameshMukka_1-1613208568630.png

    I am now splitting my task description using newline character

    split(body('Update_task_details')?['description'],decodeUriComponent('%0A'))

    RameshMukka_2-1613208647340.png

    I only want email addresses from "From:" section of the body. I can also take Cc and To if I would like to.

    RameshMukka_3-1613208736166.png

    I only want client email, it can be any. So I am just removing vendor email addresses

    RameshMukka_4-1613208846793.png

    Now I am getting client email using below formula

    if(not(empty(body('Filter_Client_Email')?[0])),first(split(last(split(body('Filter_Client_Email')?[0],'<')),'>')),'Client domain not found')

    RameshMukka_5-1613208936377.png

     

    Thanks,

    Ramesh

     

  • Verified answer
    Re: Capture Email addresses from an Email body into an array

    Hi @RameshMukka 

     

    In my understanding, you want to get the email addresses in To, From and Cc sections into an array.

     

    If I’ve misunderstood your need, please feel free to let me know.

     

    I’ve created a flow as below:

     

    Because email addresses in To, From and Cc sections are stored as string type.

     

    So, first, you can use concat() to connect those email addresses with “;”.

     

    Then, check if Cc section is empty. If empty, only connect email addresses in To, From sections. If not empty, connect email addresses in To, From and Cc sections.

     

    Last, convert the string containing all email addresses to array.

     

    The whole flow is as below:
    2.4-8.PNG

     

    The detailed steps for apply to each are:

    2.4-9.PNG

     

    The functions are:

    empty(items('Apply_to_each')?['ccRecipients'])

    concat(items('Apply_to_each')?['from'],';',items('Apply_to_each')?['toRecipients'],';',items('Apply_to_each')?['ccRecipients'])

    concat(items('Apply_to_each')?['from'],';',items('Apply_to_each')?['toRecipients'])

    split(variables('emails'),';')

     

    The output is:

    2.4-10.png

     

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

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,691

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 65,019

Leaderboard