cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mapguymike
Helper I
Helper I

Extract email address from email body - compose works on all other items I'm extracting except for the email address

I've created a flow that extracts everything I want from the body of an email but it fails to extract an email address. As I typed up this post I did more research and found that the 'at' sign is special and even within text it can be interpreted as something else. One solution I found said to use a second 'at' sign to escape it '@@'. How do I add a second symbol to the text output before I extract it?

 

 

 

The flow is triggered by the arrival of an email and converted to text from html. 

 

From: noreply@civicplus.com <noreply@civicplus.com>
Sent: Sunday, April 19, 2020 9:38 AM
To: cycling <recref@nowheremd.gov>
Subject: Online Form Submittal: Request a Scheduled Collection

 

REQUEST A SCHEDULED COLLECTION
First Name

Mary

Last Name

Holt

Address

12 Main St

City

Nowhere

State

MARYLAND

Zip

99999

Email

mmmmm2@yahoo.com

Phone

9999999999

Type of Collection

Bulk (non-metal items), Metal (e.g. appliances, metal fencing)

Please list the materials for pickup

bikes chair headboard outside glider

Tips for a Bulk Collections Pick Up

* Group materials together and separate by type. Avoid mixing different
material types.
* Materials must be easily accessible. Not blocked by vehicles.
* Avoid putting materials under power lines. Our trucks cannot pass underneath
them.

Email not displaying correctly?View it in your browser.
[http://www.nowheremd.gov/Admin/FormCenter/Submissions/Edit?id=99999&categoryID=0&formID=243&displayT...]

 

I used a series of compose steps to extract the data: For example,

trim(first(split(last(split(body('Html_to_text'),'First Name')),'Last Name')))

extracts Mary

 

As I said in the beginning, every item I was is extracted except for the email address

trim(first(split(last(split(body('Html_to_text'),'Email')),'Phone')))

 

The output shows this:

[http://www.nowheremd.gov/Admin/FormCenter/Submissions/Edit?id=99999&categoryID=0&formID=243&displayT...]

 

The pattern works after the email also: 

trim(first(split(last(split(body('Html_to_text'),'Phone')),'Type of Collection')))

9999999999

1 ACCEPTED SOLUTION

Accepted Solutions

Thanks for your reply. The email you would have seen would only have been different in its display of the \n between the words in the plain text I pasted in. I don't think it would have provided any more insight. However, I will remember that just because I can paste an email into one of these posts I should paste it in as an image.

 

I knew about replace but I realized that you would need to know the specific email address every time in order to use it. However, something in your email did give me the idea to try searching google with "power automate search string" and that led me to https://powerusers.microsoft.com/t5/General-Power-Automate/Flow-Find-Isolate-Value-within-a-String/t...

which was almost exactly my question. 

This was the answer that worked for me. 

 

trim(split(split(body('Html_to_text'),'Email:')[1],'Phone Number:')[0])

 

I understand everything in that line except for the square brackets. What do they mean?

 

View solution in original post

4 REPLIES 4
v-litu-msft
Community Support
Community Support

Hi @mapguymike,

 

You could replace() function to add the second "at", for example:

replace('Test@email.com','@','@@')

On my side, I can't see the screenshot of the output you shows, you could insert the photo into your post directly when you write the reply by clicking the "Camera" button:Annotation 2020-05-11 151226.png

 

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

Thanks for your reply. The email you would have seen would only have been different in its display of the \n between the words in the plain text I pasted in. I don't think it would have provided any more insight. However, I will remember that just because I can paste an email into one of these posts I should paste it in as an image.

 

I knew about replace but I realized that you would need to know the specific email address every time in order to use it. However, something in your email did give me the idea to try searching google with "power automate search string" and that led me to https://powerusers.microsoft.com/t5/General-Power-Automate/Flow-Find-Isolate-Value-within-a-String/t...

which was almost exactly my question. 

This was the answer that worked for me. 

 

trim(split(split(body('Html_to_text'),'Email:')[1],'Phone Number:')[0])

 

I understand everything in that line except for the square brackets. What do they mean?

 

Hi @mapguymike,

 

The output of split() function is an array, for example:

split('Test1,Test2,Test3')

the output will be:

[
"Test1",
"Test2",
"Test3"
]

The square brackets mean the sequence of the array number, the first member is [0] - "Test1", the second member is [1] - "Test2", the third member is [2] - "Test3".

After the array using the square brackets could extract the member of the array directly.

 

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

Thank for the time to explain it to me.

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (5,434)