cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Extract email content (HTML/Plaintext) and add to Excel?

Hello,

 

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

 

For example:

 

Subject: Student Applicant | James

HTML Body Preview:

<div>
<p><span>Full Name: </span><span>James</span></p>
<p><span>Email Address: </span><span>james@gmail.com</span></p>
<p><span>Phone Number: </span><span>08080808080</span></p>
</div>

Looks like:

Full Name: James

Email Address: james@gmail.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.

5 REPLIES 5
Anonymous
Not applicable

Hi,

 

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).

Screencap1.png

- 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): 

replace(variables('htmltest'),'</span></p>',':')
 
- Then I used "HTML to TEXT" to strip all HTML content from your form. 
 
- I added a compose and entered this expression to split the text on the colon seperator:
split(body('Html_to_text'),':')
screencap3.png

 

- I Initialized a variable of type Array and added the output of the Compose action.
screencap2.png

 

 
- Then I created a variable for email adress and used the following expression to extract the mail address. You can do the same with another string variable for the name and phone number.
 
expression: 
variables('test')[3]
 
I named the array variable test. The 3 is the index of the mail of the student. This blogpost will help you with arrays and indexes.
 
I hope this helps you on your way. I did this quick and it is probably far from perfect. There will be other ways of doing this I guess. Let me know if I can do anything else for you.
 
If you are new be sure to check out the videos of Shane Young on Youtube. He made a few videos on Flow (and is normally going to do more).
 
And don't forget to watch the videos on MS Flow made by Laura Rogers. Here is her youtube channel. And here are the official docs.
v-yuazh-msft
Community Support
Community Support

Hi @zak-elatt,

 

@Anonymous 's solution is able to acheive your requirement.

Have @Anonymous answered your question?

 

If your question haven't been solved,please share more details about the Excel table and I would offer you the special workaround with steps.

 

Best regards,

Alice

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.

Hi there, i'd really appreciate it if you were able to also contribute with some examples or solutions if you had any to give us any ideas!

Anonymous
Not applicable

Hi,

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:

Screencap1.png

 

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.

screencap2.png

Step 3: I created another string variable called "add seperator" and used the following formula: 

replace(variables('htmltest'),'</span></p>',':')
 
This is a replace formula. I took the variable named 'htmltest' (name of the variable in step 2) and replaced every occurence of </span></p> with a colon. This is important later in the example flow I quickly put together. I use the colon to split the HTML input into an array (next steps) so that we can work with the data (mail adres, name, ...) as seperate columns (like and Excel table or CSV).

 

screencap3.png

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).

 

 screencap4.png

 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.

screencap5.png

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.

 

 

screencap6.png

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')[3]

 

 screencap7.png

 

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!    This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Community MembersNumber SolutionsSuper UsersNumber Solutions Deenuji 9 @NathanAlvares24  17 @Anil_g  7 @ManishSolanki  13 @eetuRobo  5 @David_MA  10 @VishnuReddy1997  5 @SpongYe  9JhonatanOB19932 (tie) @Nived_Nambiar  8 @maltie  2 (tie)   @PA-Noob  2 (tie)   @LukeMcG  2 (tie)   @tgut03  2 (tie)       Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 2: Community MembersSolutionsSuper UsersSolutionsPower Automate  @Deenuji  12@ManishSolanki 19 @Anil_g  10 @NathanAlvares24  17 @VishnuReddy1997  6 @Expiscornovus  10 @Tjan  5 @Nived_Nambiar  10 @eetuRobo  3 @SudeepGhatakNZ 8     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 3:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji32ManishSolanki55VishnuReddy199724NathanAlvares2444Anil_g22SudeepGhatakNZ40eetuRobo18Nived_Nambiar28Tjan8David_MA22   Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 4:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji11FLMike31Sayan11ManishSolanki16VishnuReddy199710creativeopinion14Akshansh-Sharma3SudeepGhatakNZ7claudiovc2CFernandes5 misc2Nived_Nambiar5 Usernametwice232rzaneti5 eetuRobo2   Anil_g2   SharonS2  

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages