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.
@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
Update my planner task description with convert body text
I am now splitting my task description using newline character
split(body('Update_task_details')?['description'],decodeUriComponent('%0A'))
I only want email addresses from "From:" section of the body. I can also take Cc and To if I would like to.
I only want client email, it can be any. So I am just removing vendor email addresses
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')
Thanks,
Ramesh
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:
The detailed steps for apply to each are:
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:
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.