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

Extract email address from PowerApps dynamic email field and send email using Power Automate

I created an inspection form in Power Apps for site visits. The inspection form has an email field that the inspector will populate with the site business owner's address to email a PDF copy of the inspection report. I've figured out a way to extract the email address using this Shane Young video: Turn emails into data - Flow String functions, Email with options, terminate, and more. The problem is that in his video he uses character count to extract a name from a form,  I tried using the same method to extract the email address from my form.  So I used some of his methods but inserted some of my own since the email field in my form is dynamic, I inserted an HTML to Text action (to extract the email and turn it into a text string), followed by an Initialize variable action (for the converted email text string). However, as I suspected, it worked with the content I had in the form but once I changed the content, it didn't work because the character count changes when the content changes.

ljkeefe_0-1651866524831.png

 

This is the rest of my Flow 

ljkeefe_1-1651866744695.png

 

I have found similar posts but it is usually regarding a static email address in Flow. I'm very close, I was able to make Shane's method work but as I stated, it didn't account for the fields before to be dynamic and change the character count.

Your help is appreciated.

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions

I had to make a slight modification to my solution and have tested it with different email addresses and filling out the form and it works....thank goodness. So still a variation on Shane's email: 

1. I created a Compose action, as he does to find the "Email:" string in my HTML, however, I included the Add expression with the IndexOf expression he uses to account for the characters of Email: which as you can see below is 6 characters which finds the email in the string. 

 

Add(indexOf(triggerBody()['text'],'Email:'), 6)

 

 Then the rest from the previous solution: 

 I then used his method of ending that field by using the closing html tag with the use of another Compose action using the indexOf expression.

indexOf(outputs('email'),'</p>')

  Created another Compose action for drawing out the Email only, using the substring expression:

substring(outputs('email'),0,outputs('EndOfEmail'))

 Then used the Html to Text action, selecting the EmailOnly output. 

Created a variable with Initialize variable using the Html to Text action at the value. Then I used this variable in the To: field in the Send an email action. 

 

Now it works!!

View solution in original post

3 REPLIES 3
ljkeefe
Helper I
Helper I

Nevermind. I actually figured it out using Shane's method in a roundabout way. Instead of calculating the start of the field, I calculated the end of the field where the actual email address would begin. I then used his method of ending that field by using the closing html tag with the use of another Compose action using the indexOf expression.

indexOf(outputs('email'),'</p>')

  Created another Compose action for drawing out the Email only, using the substring expression:

substring(outputs('email'),0,outputs('EndOfEmail'))

 Then used the Html to Text action, selecting the EmailOnly output. 

Created a variable with Initialize variable using the Html to Text action at the value. Then I used this variable in the To: field in the Send an email action. 

ljkeefe
Helper I
Helper I

After several tests, this method does not extract just the email from the form using the number of characters. Help is appreciated!

 

I had to make a slight modification to my solution and have tested it with different email addresses and filling out the form and it works....thank goodness. So still a variation on Shane's email: 

1. I created a Compose action, as he does to find the "Email:" string in my HTML, however, I included the Add expression with the IndexOf expression he uses to account for the characters of Email: which as you can see below is 6 characters which finds the email in the string. 

 

Add(indexOf(triggerBody()['text'],'Email:'), 6)

 

 Then the rest from the previous solution: 

 I then used his method of ending that field by using the closing html tag with the use of another Compose action using the indexOf expression.

indexOf(outputs('email'),'</p>')

  Created another Compose action for drawing out the Email only, using the substring expression:

substring(outputs('email'),0,outputs('EndOfEmail'))

 Then used the Html to Text action, selecting the EmailOnly output. 

Created a variable with Initialize variable using the Html to Text action at the value. Then I used this variable in the To: field in the Send an email action. 

 

Now it works!!

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

Top Solution Authors
Users online (1,873)