I'm using a contact form plugin on a website to collect form submissions which get emailed to me.
These emails are templated, so the subject is set, there are fields/values set all in HTML as well with values on each line
Subject: Student Applicant | James
HTML Body Preview:
<div> <p><span>Full Name: </span><span>James</span></p> <p><span>Email Address: </span><span>firstname.lastname@example.org</span></p> <p><span>Phone Number: </span><span>08080808080</span></p> </div>
Full Name: James
Email Address: email@example.com
Phone Number: 080808080
Now, I'm using Office 365 for Business. I've setup an email rule so that subjects with the above term automatically go into the "Students" email folder.
From Flow, I've created the first step which collects an email once it arrives in that folder, which is fine.
I also have an Excel Spreadsheet in my OneDrive Business which has a table with columns: "Full Name", "Email Address" and "Phone Number".
Now here's the problem: how can I select each value from the email body?
I want to be able to select the value of "Full Name" which is "James" and make sure that can be added to the spreadsheet, but the main problem is I can't even select these values.
I was wondering if JSON Parse can help, but I have no experience in using JSON or know how the functions work in Flow. I've got experience in programming, but this is a little out of scope from what I've done before.
Any suggestions would be greatly appreciated! Thank you.
I made a quick example to help you on your way. I'm still learning a lot myself, so this my be one way to get there. But there will be others. Maybe others will chip in as well.
So here is the screencap of what I came up with (I used the HTML example you posted).
- I saved your HTML example into the first variable (named 'htmltest'). The first operation I did is sort of a hack to get everything to work. I noticed the colon between the column names (like Firstname) and the name itself. I wanted to split the text on colon so that I can put everything into an array.
- I created a variable that replaced every "</span></p>" combination with a colon :
This was the expression used in the variable (add seperator):
Thank you! And sorry for the late reply. I've tried to understand your solution as much as I can. I can understand most of the last part I think, though I was wondering mostly how I can capture the body of the email in its HTML format and pick out each part.
And I don't clearly understand why some elements are used e.g. Compose.
Would it be alright if you expanded all the elements and showed me what each part contains so I can see how I can adapt mind and try it out, from the very beginning (Initialise Variable HTML). Also, another weird issue is that I can't find "Initialise Variable HTML" but only "Initialise Variable".
Thanks. I really appreciate your feedback! It's the closest I've gotten so far.
Here are the screenshots you asked. I described everything in my previous post. These screencaps should help you further on your way. Try and follow the steps below in my example. This should help you on your way. Can you following along these 7 steps in your own Flow? If you can build this and it works, I guess you have the basis for your own solution. Can you try to copy the steps and let me know?
Example flow screenshot:
Step 1 is the trigger (manual button trigger, not important for you. The trigger for your actual flow would be an email you receive.
Step 2: part of the example. I added a variable (type string) and pasted in the example HTML you provided to work with.
Step 3: I created another string variable called "add seperator" and used the following formula:
Step 4: Now that the colons are in place I use the HTML to text action to remove all the extra HTML from the example (this will also strip all HTML from an email you would receive).
Step 5: I use the compose action. The compose is just a blank "canvas" action you can use to work with text, JSON or just about anything else. Here I use it to split the output from the HTML_to_text action.
Look at the formula: split(body('Html_to_text'),':')
I split the text into an array using the colon (:). I added this in step 2. Thanks to the split I will now be able to extract the important information that you require, such as the mail or name.
Step 6: Here I just created a variable namd test of type 'Array'. The output of the compose action was added as the value of this variable.
Step 7: Since I now have an array with all the information you need. I made a variable for the mailadress. The value was retrieved from the array. Each part of information (name, mail, ...) in an array has a number. Using the number you can retrieve the information and put it in a variable. This variable can than be used in your flow. For instance you can write this value to an excel document or to a sharepoint list (create sharepoint list item action).
Here is the formula: variables('test')
Fill out a quick form to claim your user group badge now!
We've given our badges an overhaul and also added some brand new ones!
Learn how to build the business apps that you need.
Find out where you can attend!
Watch & learn from the Power Automate Community Video Gallery!