cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
000_JP
Level: Power Up

Read email content from body of the email, extract and create conditions or actions

I would love to be able to create a flow that can read the body of the email not just subject or attahcments names.  Once it can read the body of the text and find key words, extract some of this content. Identify if its a date or string and create a calendar event, etc. 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Read email content from body of the email, extract and create conditions or actions

Hi @000_JP,

 

Could you please share an example about your scenario?

Do you want to extract content from body of the email?

 

I assume that the details of your incoming email as below and you want to extract the Subject and End time content from Body of the email:2.JPGI have made a test on my side and please take a try with the following workaround:

  • Add a "When a new email arrives" trigger.
  • Add a "Html to text" action, Content field set to Body dynamic content of the trigger.
  • Add a "Compose" action, Inputs set to following formula:
  • length(body('Html_to_text'))
    Add a "Compose 2" action, Inputs set to following formula:

 

add(indexOf(body('Html_to_text'),'End time'),10)
  • Add a "Compose 3" action, Inputs set to following formula:
  • substring(body('Html_to_text'),outputs('Compose_2'),sub(outputs('Compose'),outputs('Compose_2')))
    Add a "Compose 4" action, Inputs set to following formula:
  • add(indexOf(body('Html_to_text'),'Subject'),9)
    Add a "Compose 5" action, Inputs set to following formula:
  • indexOf(body('Html_to_text'),'Start time')
    Add a "Compose 6" action, Inputs set to following formula:
  • substring(body('Html_to_text'),outputs('Compose_4'),sub(outputs('Compose_5'),outputs('Compose_4')))
    Add a "Create event (V1)" action, specify Calendar id, End time field set to output of "Compose 3" action, Start time field set to following formula:
utcNow()

Subject field set to output of "Compose 6" action.

 

Image reference:3.JPG

 

4.JPG

The flow works successfully as below:5.JPG7.JPG

 

6.JPG

 

Best regards,

Kris

 

 

 

 

 

 

 

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
7 REPLIES 7
Community Support Team
Community Support Team

Re: Read email content from body of the email, extract and create conditions or actions

Hi @000_JP,

 

Could you please share an example about your scenario?

Do you want to extract content from body of the email?

 

I assume that the details of your incoming email as below and you want to extract the Subject and End time content from Body of the email:2.JPGI have made a test on my side and please take a try with the following workaround:

  • Add a "When a new email arrives" trigger.
  • Add a "Html to text" action, Content field set to Body dynamic content of the trigger.
  • Add a "Compose" action, Inputs set to following formula:
  • length(body('Html_to_text'))
    Add a "Compose 2" action, Inputs set to following formula:

 

add(indexOf(body('Html_to_text'),'End time'),10)
  • Add a "Compose 3" action, Inputs set to following formula:
  • substring(body('Html_to_text'),outputs('Compose_2'),sub(outputs('Compose'),outputs('Compose_2')))
    Add a "Compose 4" action, Inputs set to following formula:
  • add(indexOf(body('Html_to_text'),'Subject'),9)
    Add a "Compose 5" action, Inputs set to following formula:
  • indexOf(body('Html_to_text'),'Start time')
    Add a "Compose 6" action, Inputs set to following formula:
  • substring(body('Html_to_text'),outputs('Compose_4'),sub(outputs('Compose_5'),outputs('Compose_4')))
    Add a "Create event (V1)" action, specify Calendar id, End time field set to output of "Compose 3" action, Start time field set to following formula:
utcNow()

Subject field set to output of "Compose 6" action.

 

Image reference:3.JPG

 

4.JPG

The flow works successfully as below:5.JPG7.JPG

 

6.JPG

 

Best regards,

Kris

 

 

 

 

 

 

 

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
000_JP
Level: Power Up

Re: Read email content from body of the email, extract and create conditions or actions

Kris,

 

My apologies for the late reply. I appreciate how creative the proposed solution is!

 

 

Thank you,

 

JP 

Edegress
Level: Powered On

Re: Read email content from body of the email, extract and create conditions or actions

Thanks for the detailed desciption, I tried to run it as described above but hot the following error;

 

The string was not recognized as a valid DateTime. There is an unknown word starting at index 10. clientRequestId: c7e6674c-5d20-458b-b65a-c692c6fef136

WillPage
Level 8

Re: Read email content from body of the email, extract and create conditions or actions

@v-xida-msft I know this is an old thread, but I found it while looking for a solution to the same problem.

 

The difference with mine is the data I'm looking for doesn't match a nice pattern that can be easily defined by say.. add(indexof ......), 10

 

For example the email has this data:

 

Enquiry from: Firstname Lastname
Email: user@gmail.com
Phone Number: 0299999876
First Night: Thursday, 17 January 2019
Number of Nights: 2

 In each of these lines the number of characters to add to the indexof is different for each email.

 

How can I use a function to grab everything between the colon and the new line, trim it and place it in a variable?

 

I will also put this in a new thread.

HallieG
Level: Powered On

Re: Read email content from body of the email, extract and create conditions or actions

Hi @Kris

 

Can you explain how to convert this example if the details repeated, how to loop through all iterations? I have a similar case, the number of items per email does very.

 

Outlook Calendar event details as below

Subject: FirstTestEvent
Start Time: 4/20/2019
End Time: 4/21/2019

 

Subject: SecondTestEvent
Start Time: 4/21/2019
End Time: 4/22/2019

 

Subject: ThirdTestEvent
Start Time: 4/22/2019
End Time: 4/23/2019

 

 

 

WillPage
Level 8

Re: Read email content from body of the email, extract and create conditions or actions

@HallieGUse the Split() expression to split on 'Subj' and then run the resulting array through a for-each.

sxt173
Level: Powered On

Re: Read email content from body of the email, extract and create conditions or actions

Did you find any solutions to this? I'm trying to figure the same thing out. How to do this for data that might be a bit unstructured. For example, how do I grab whatever is between a "$" and ":" sign?

>