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 / get mail address from ...
Power Automate
Answered

get mail address from string

(0) ShareShare
ReportReport
Posted on by 15

Hi 

 

I have the following string: 

 

daverndn@gmail.comNamedaveCompanytestPhone Number54249448178CountryBrazil
State / ProvincePage URL....more text

 

How could I extract or identify just the mail address? 

 

thank you!

 

 

Categories:
I have the same question (0)
  • DaveR Profile Picture
    15 on at

    after some testing, figured out the solution: 

     

    substring(body('Html_to_text'),add(indexOf(body('Html_to_text'),'Email Address'),14),sub(indexOf(body('Html_to_text'),'Name'),add(indexOf(body('Html_to_text'),'Email Address'),14)))

     

    thanks!

  • Ed Gonzales Profile Picture
    4,531 Most Valuable Professional on at

    @DaveR 

    Yours is way different than what I was going to suggest, but use the one that works best for you.   I was going to suggest splitting the string at the word "Name" and grabbing everything before that:

     

    split(outputs('SampleData'),'Name')[0]
     
    Will also work.
    -Ed-
     
     

    If you liked this reply, please give it a thumbs up! If this reply has answered your question or resolved your challenge, please consider marking it as a Solution. This helps other users find it more easily via search.

  • DaveR Profile Picture
    15 on at

    Hi @edgonzales 

     

    Thanks for your quick response, 

     

    Your approach looks easier and more straight forward!

     

    Could you ellaborate a bit more on how would this apply?

     

    Example of the plain text

    "lp-form/ Keywords: Email address daverndn@gmail.comNamedaveCompanytestPhone Number54249448178CountryBrazil
    State / ProvincePage URL....more text"

     

    I have the following flow: 

     

    1. When an email arrives

    2. HTML to text

    3. Compose1 (Input: fx length(body('Html_to_text')))

    4. Compose2 (Input: fx add(indexOf(body('Html_to_text'),'Email Address'),14))

    5. Compose3 (Input: fx 

    substring(body('Html_to_text'),add(indexOf(body('Html_to_text'),'Email Address'),14),sub(indexOf(body('Html_to_text'),'Name'),add(indexOf(body('Html_to_text'),'Email Address'),14))))
     
    flow.png
     
    So far this gets the mail address, but when adding special characters before or after the mail/different length, might not work. 
     
    Thanks!
  • Ed Gonzales Profile Picture
    4,531 Most Valuable Professional on at

    @DaveR 

    You bet.  So, check out this blog where I go into more detail on Split.  The main thing with any kind of string/text manipulation is that the inputs need to be consistent, right?  Looking at your example:

     

    lp-form/ Keywords: Email address daverndn@gmail.comNamedaveCompanytestPhone Number54249448178CountryBrazil
    State / ProvincePage

     

    We have an opportunity to isolate the email address by breaking the text first at 'Name' and then again at 'address '.  With Split, you can identify a delimiter, and it will break that string of text into an Array.  Since Arrays have 'elements', you can indicate which element you are interested in using an integer (keeping in mind that they start at zero).

     

    Using my example above (where I didn't know the stuff before the email address), you would end up with two elements in the array:

     

    lp-form/ Keywords: Email address daverndn@gmail.com would be the first one ([0]) and 

     

    daveCompanytestPhone Number54249448178CountryBrazil State / ProvincePage would be [1].

     

    My original expression had the [0] at the end, so we will only be working with the part that starts with 'Ip-form/'.

     

    We can further break that down using the same technique either in a follow up Compose, or by wrapping our new expression around the first one, like this (new parts are in bold):

     

    Split(split(outputs('SampleData'),'Name')[0],'address ')[1] 

     

    (note the space after 'address' is included in the delimiter).  That should break things down so the final array is:

     

    lp-form/ Keywords: Email is the first element [0]

    daverndn@gmail.com is the second element [1]  (that's the one we want)   Notice that your delimiter ('address ') isn't in either.

     

    Kep us posted.

    -Ed-

     

    If you liked this reply, please give it a thumbs up! If this reply has answered your question or resolved your challenge, please consider marking it as a Solution. This helps other users find it more easily via search.

     

     

     

  • DaveR Profile Picture
    15 on at

    Thanks @edgonzales

     

    So I just tried the following: 

     

    Compose 3: includes the output - string format - 

     

    Compose 4: added the split function as follows: 

    Split(split(outputs('Compose_3'),'Name')[0],'address ')[1]
     
    tstflow.png
    tstflow2.png
     
    I´m getting an error on the array being outside of bounds(0,0), any thoughts?
     
    Thank you!
     
     
  • Verified answer
    Ed Gonzales Profile Picture
    4,531 Most Valuable Professional on at

    So, notice that there's a difference in this data and the original?  If the input is not consistent, this stuff won't work.

    The word, Address is capitalized now and there is no space after, so it's not recognizing the breakpoint.

     

    Try: Split(split(outputs('SampleData'),'Name')[0],'Address')[1]

     

    Keep us posted.

    -Ed-

     

    If you liked this reply, please give it a thumbs up! If this reply has answered your question or resolved your challenge, please consider marking it as a Solution. This helps other users find it more easily via search.

  • DaveR Profile Picture
    15 on at

    Hi @edgonzales 

     

    Thanks for your time and effort invested on this question, I just tested it and now is working as expected, really appreciate your help!

     

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

#2
Tomac Profile Picture

Tomac 324 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard