Hello, I am trying to parse text from an incoming email to a Sharepoint list like it is described in this tutorial (https://youtu.be/OrCs36S3w3w).
The difference is that the incoming email is already in text instead of HTML.
So I skipped the HTML to text connector and changed the expression for parsing the text like this:
original expression: first(skip(split(first(split(body('Html_to_text'),'Quantity')),': '),1))
adjusted: first(skip(split(first(split(triggerOutputs()?['body/body'],'Quantity')),': '),1))
Intention is to skip the not required "HTML to text" and get the text directly out of the email body.
But unfortunately I get the message that the printout is invalid.
Can anyone help me?
Thank you very much...you are really awesome 😄
Put the expression trim() around the full expression and it will remove the beginning and ending spaces.
trim(first(skip(split(triggerOutputs()?['body/body'],'Delivery Method:'),1)))
Or for your example
trim(first(skip(split(triggerOutputs()?['body/body'],'Nachrishtentext:'),1)))
thank you very much again. It works almost perfect the only minor error is that the parsed text does not start with the first letter. the is space or line break before. first picture is the incoming email and the second is the result in the form
Thank you for the photo of the email format. That made a difference. If you ask for help again on the forum it is beneficial to include your specific information for your flow. Especially screenshots.
The space at the end of 'Delivery Method: ' is what is causing the problem. The split is looking for a space to be after the colon: so when it doesn't find a space it doesn't do the split.
Your email doesn't have a space after your word 'Nachrichtentext: ' like the split expression is searching for.
Your email has a line break which is different than a space. So basically remove the space to make it 'Nachrichtentext:' and you will get the remaining text.
first(skip(split(triggerOutputs()?['body/body'],'Delivery Method:'),1))
Or using your example
first(skip(split(triggerOutputs()?['body/body'],'Nachrishtentext:'),1))
I tested with my flow and it worked. It should work for you as well.
thank you very much for your great support. Sadly the expression doesn't work so far - the expression is providing no result. I added a screenshot of the incoming email and the expression of your reply adjusted with the entry of the incoming mail.
first(skip(split(triggerOutputs()?['body/body'],'Nachrichtentext: '),1))
the expression should provide the result: test test test --> but the result is: 0
I think it would help if you separated the individual expressions within the full expression for each final output you are trying to get.
The video link doesn't do a good job explaining what is going on within the expression, so it is difficult for to catch errors or adjust for any changes with your text or email.
To separate the first expression which gets the example Cookie Type there are 5 individual expressions that builds the full expression.
first(skip(split(first(split(triggerOutputs()?['body/body'],'Quantity')),': '),1))
The full Cookie Type expression says:
split(triggerOutputs()?['body/body'],'Quantity')
first(split(triggerOutputs()?['body/body'],'Quantity'))
split(first(split(triggerOutputs()?['body/body'],'Quantity')),': ')
skip(split(first(split(triggerOutputs()?['body/body'],'Quantity')),': '),1)
first(skip(split(first(split(triggerOutputs()?['body/body'],'Quantity')),': '),1))
To separate the second expression which gets the example Quantity there are also 5 individual expressions that builds the full expression.
first(skip(split(first(split(triggerOutputs()?['body/body'],'Delivery Method')),'Quantity: '),1))
The full Quantity type expression says:
split(triggerOutputs()?['body/body'],'Delivery Method')
first(split(triggerOutputs()?['body/body'],'Delivery Method'))
split(first(split(triggerOutputs()?['body/body'],'Delivery Method')),'Quantity: ')
skip(split(first(split(triggerOutputs()?['body/body'],'Delivery Method')),'Quantity: '),1)
first(skip(split(first(split(triggerOutputs()?['body/body'],'Delivery Method')),'Quantity: '),1))
The final expression which gets the Delivery Method only has 3 individual expressions that builds the full expression. However, it will get all remaining text in the email if there is anything like a Signature Name in the email body.
first(skip(split(triggerOutputs()?['body/body'],'Delivery Method: '),1))
The full Delivery Method type expression says:
split(triggerOutputs()?['body/body'],'Delivery Method: ')
skip(split(triggerOutputs()?['body/body'],'Delivery Method: '),1)
first(skip(split(triggerOutputs()?['body/body'],'Delivery Method: '),1))
I made an example flow that split the full expressions into each of it's individual expressions. The example flow uses the previous output to fill in the next expression value.
So Step A1 is the first part of the expression for Cookie Type, and then Step A2 uses the output of A1 to use it's individual expression. The final step A5 will be the same output as the full expression in A99 for cookie type.
The A99 step, B99 step, C99 step are all full expressions that would be similar to what you would use in your flow.
Full Example Flow
I separated my example flow into different Scope for each full expression.
Scope A is for the Cookie Type
Example Flow Scope A Cookie Type
Scope B is for the Quantity
Example Flow Scope B Quantity
Scope C is for the Delivery Method
Example Flow Scope C Delivery Method
The results of my example flow show how each individual part of the expression is using the outputs of the previous flow step.
I made an example Plain Text email for the trigger body.
The difference with my example email is that it has additional name signature information at the end. I included that to show that the final expression for Delivery Method will pull in additional text from the email body if it is not correctly changed for your situation.
Below is the example Email I used:
Example Email Plain Text
Below is the results of Scope A to get Cookie Type:
[
"Cookie Type: Chocolate Chip\r\n",
": 20\r\nDelivery Method: Pigeon\r\n\r\n\r\nMYName And Signature\r\nMyPhoneNumber 888-999-9999\r\n"
]
Cookie Type: Chocolate Chip
[
"Cookie Type",
"Chocolate Chip\r\n"
]
[
"Chocolate Chip\r\n"
]
Chocolate Chip
Results Scope A Cookie Type
Below is the results of Scope B to get Quantity:
[
"Cookie Type: Chocolate Chip\r\nQuantity: 20\r\n",
": Pigeon\r\n\r\n\r\nMYName And Signature\r\nMyPhoneNumber 888-999-9999\r\n"
]
Cookie Type: Chocolate Chip
Quantity: 20
[
"Cookie Type: Chocolate Chip\r\n",
"20\r\n"
]
[
"20\r\n"
]
20
Full Scope B results
Scope B Results
Below is the results of Scope C to get Delivery Method
Delivery Method type expression says:
[
"Cookie Type: Chocolate Chip\r\nQuantity: 20\r\n",
"Pigeon\r\n\r\n\r\nMYName And Signature\r\nMyPhoneNumber 888-999-9999\r\n"
]
[
"Pigeon\r\n\r\n\r\nMYName And Signature\r\nMyPhoneNumber 888-999-9999\r\n"
]
Pigeon
MYName And Signature
MyPhoneNumber 888-999-9999
Results Scope C Delivery Method
I hope these examples help you create an expression to get the information you need. It is probably best if you understand the individual expressions that are building the full expression so that you can adjust or change things to accommodate your individual situation.
Cookie Type Full Expression:
first(skip(split(first(split(triggerOutputs()?['body/body'],'Quantity')),': '),1))
Quantity Full Expression:
first(skip(split(first(split(triggerOutputs()?['body/body'],'Delivery Method')),'Quantity: '),1))
Delivery Method Full Expression:
first(skip(split(triggerOutputs()?['body/body'],'Delivery Method: '),1))
Let me know if this works for you,
I am still struggling with the expression for the last part. I used your expression for the middle text, but the for the last one I am told that my expression is not guilty.
I used this one:
Great! Glad to hear it is working.
If this post is resolved please mark the response as a solution so other people can easily reference it.
thank you very much. your expression is working 🙂 , but in my incoming email there is a dress to be parsed - using the the trim() it would only parse the first word of the text.
Thank you very much for support
Can you show a screenshot of the incoming email how it looks in your inbox and also a screenshot of the input results of your flow that failed with the error? It would be helpful to see what you have.
I used the expression below and was able to get a Plain Text Email body to give me the response Chocolate Chip like in the video example.
first(skip(split(first(split(triggerOutputs()?['body/body'],'Quantity')),': '),1))
I would add a Trim() to the expression so that it removes any trailing or leading spaces or line breaks.
trim(first(skip(split(first(split(triggerOutputs()?['body/body'],'Quantity')),': '),1)))
(Note: When I was testing, right after I pressed Save and Test, I kept getting a message "Cannot read properties of undefined (reading 'properties')" and the flow would not test. However, I would just press the Save and Test again, and the flow would work. Seems like it is probably because I keep reusing a test flow for looking at questions on here.)
WarrenBelz
146,635
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,997
Most Valuable Professional