Skip to main content

Notifications

Power Automate - Building Flows
Unanswered

Pulling information from an email body

Posted on 2 Dec 2024 23:01:52 by 80
Hello!
 
We receive airfare emails for our event attendees. Because I do not have AI Builder, I am pulling the information from the email body instead of from the attached Airfare Invoice.  The goal is to rename the invoice with specific information.  I have been able to successfully do this in all but one scenario through a series of Compose actions and a Filter Array.
 
Current flow searches for the word "Destination:" and returns what comes after it.  This works great, unless the person has a layover.  I need the final destination of the outbound trip pulled in order to rename the attached PDF correctly.
 
1.) When a new email arrives...
2.)  HTML to Text
a. triggerOutputs?()['body/body']
3.) Initialize Variable
a. Type = String
b. body('Html_to_text']
4.) Compose - Find Destination
a. substring(variables('varEmailBody'), add(indexOf(variables('varEmailBody'), 'Destination:'), 12), sub(length(variables('varEmailBody')), add(indexOf(variables('varEmailBody'), 'Destination:'), 12)))
5.) Compose - New Line
a. //carriage return
6.) Compose - Split Destination Lines
a. split(outputs('Compose-Find Destination'), outputs('Compose-newline'))
7.) Filter Array - Destination
a. From: Outputs['Compose - Split Destination Lines']
b. Filter Query: length(trim(item())) is greater than  0
8.) Compose - Destination Line
a. body('Filter_array_Destination')?[0]
9.) Compose - Destination Final
a. trim(split(outputs('Compose - Destination Line'),',')[0])
 
Assuming the below itinerary is in the body of the email, the flow would pull New York.  How do i get it to pull Destination 1 (New York) when there is no layover, and Destination 2 (Boston) when there IS a layover?  Keeping in mind that the return flights are also in this email body, so there would be (a) return Destination(s) that should not be taken into account.
Flight 9:00AM
 Flight Information
Carrier: Delta Air Lines Inc
Flight: DL 12345
Class: Economy
Origin: Los Angeles, CA
Departing: Monday 09 December 2024 at 9:00AM
Destination: New York, NY, New York LaGuardia Apt (LGA)
Arriving: Monday 09 December 2024 at 10:45AM
Flight 12:00AM
 Flight Information
Carrier: Delta Air Lines Inc
Flight: DL 54321
Class: Economy
Origin: New York, NY, New York LaGuardia Apt (LGA)
Departing: Monday 09 December 2024 at 12:00AM
Destination: Boston, MA, Boston Edward L Logan Intl Apt (BOS)
Arriving: Monday 09 December 2024 at 1:20PM
 
Would appreciate any help you can provide!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #7 Community Profile Tips…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,297

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 63,890

Leaderboard