cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ljkeefe
Resolver I
Resolver 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
Resolver I
Resolver 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
Resolver I
Resolver 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 Automate News & Announcements

Power Automate News & Announcements

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

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (4,546)