I’ve got a Logic App that reads in an email from a form submission. Unfortunately, I only have access to the email and not where the form results are stored, so I currently have the Logic App set up to pull in the email and convert it to text.
If it was just one field, I assume I could just grab it all, throw it in a variable and split it to get what I need, but I’m not sure how to do this with multiple lines.
The emails always come in with this format:
—
Date: 08/18/2022
Time: 09:30:00
Requestor Name: Robert Bobson
Requestor Email: [email protected]
Requestor Phone Number: 800-867-5309
Site Name: CompanyName
Site Number: 123456789
—
Am I able to set a line index and then grab everything on that line and then split it before assigning it to a variable? Is this going to require RegEx or is there a workaround or expression in Logic Apps that will handle this?
Thank you in advance!
2
Answers
You can Convert the email body using "Html To Text" action and then assign it to an array variable by using the split expression for any delimiter.
You can achieve your requirement using expressions.
First, try removing the extra lines from the given email. below is the expression I’m using to achieve the same.
The above expression results in:
yes, This is possible using the below expression
RESULTS:
Alternatively, You can convert the string into Parsable Json and then Parse it through Parse JSON Action. Below is the flow of my Logic App
In the above step I’m extracting the values on both left and right sides and storing them into a variable. You can use either of slice or substring functions to extract the values.
In the next step I’m trying to Parse the values through Parse JSON action.
RESULTS:
You can test the same using below code view in your logicapp