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 / Extract email from tex...
Power Automate
Answered

Extract email from text body to use as sender

(0) ShareShare
ReportReport
Posted on by 66

Hello,

 

I get the text below as an automated email notification. The email body is the only place where I can get the email address for the person who placed the access request.

 

John Smith (jsmith@company.com) has requested access to your hub.

 

How can I extract the email from the email body - in this case "jsmith@company.com", and use it on the To: field in the Send Email Action?

I would like to do this to every email that requests access.

 

Thank you in advance.

 

 

Categories:
I have the same question (0)
  • Verified answer
    Fjgomez2 Profile Picture
    22 on at

    Extracting the requestor's email out of the email body will require a few different steps.

     

    To start: You want to use the Trigger 'When a new email arrives (V3)' and use the Subject filter to make sure you are only looking at the emails that are requesting access. Based on what you have provided this subject line should be the same or all start the same for all request emails making this easy to fill in.

     

    You then want to convert the content of the email into plain text using the 'Html to text' connector and put in your Email Body into this action.

    Fjgomez2_0-1699048296453.png

     

    From your description you can be sure that the email will always be surrounded by parentheses so we can use those characters to find the start and end place of your email.

     

    To find the beginning index:

     

    add(indexOf(outputs('Html_to_text')?['body'],'('),1)

     

    Note: We add one to the index of the opening parenthesis as we do not want to include it in our email

     

    To find the end index:

     

    indexOf(outputs('Html_to_text')?['body'],')') 

     

     

    For my example I have placed all formulas used into their own 'Compose' Functions. You can then extract the text from within the two indices using the following formula:

     

    substring(outputs('Html_to_text')?['body'],outputs('Get_Start_of_Email'),sub(outputs('Get_End_of_Email'),outputs('Get_Start_of_Email'))) 

     

     

    Finally, your email should be extracted and you can use the output of your final compose to send out a reply email. I've added an image below to show how it all looks, Hope this helps! 

    Fjgomez2_0-1699049561959.png

     

  • jagostinho_CT Profile Picture
    66 on at

    thank you, but I am looking for a solution that will not involve a subscription.

  • jagostinho_CT Profile Picture
    66 on at

    thank you @Fjgomez2 , for the detailed step-by-step. It was clear and very useful.

    I am, however, getting an error. I think it is because the Start and End of email outputs are using a String format but the last Email of Requestor action requires them to be integers. 

     

    But I do not know how to convert the outputs to a different data type.

    😞

     

    jagostinho_CT_0-1699531090873.png

     

  • Fjgomez2 Profile Picture
    22 on at

    @jagostinho_CT  You can convert a string to a number using the int(Value to Convert) function although IndexOf should be returning a number

  • jagostinho_CT Profile Picture
    66 on at

    It is working now! Many thanks @Fjgomez2 

  • DeeDeeLis Profile Picture
    2 on at

    I am looking for a solution for a string where I dont know where or IF there is an email address present. is it  possible to use a regex? 

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 503 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 321 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard