Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Answered

flow reading email body, adjust for more or less data

(0) ShareShare
ReportReport
Posted on by 114

Hi Power Automate Community,

I have a flow that is set to read incoming email body. it takes that body and splits it and extracts the data. its rather long roughly 37 different lines after being split.  I have changed the flow to adjust for the first example that has come in, however after the second email came in there was slight difference in the layout.  The reason was in a segment to be read there was less data.

 

for example. 

[0] Address line 1

[1] address line 2

[2] address line 3

[3] city, state zipcode

[4] contact information

[5] 

[6] Order Information

[7] TCN: ### ### ###

[8] 

[9] CLIN details

[10] 1 #### ####          #####                #####     ####

 

 

in this example. i set the data to be reading the address data and CLIN details (order details).  but in the second email i received. instead of CLIN being line [10] it was line [8]. the reason was that the address was in the US vs international and the fields were 2 less.

 

my original thought would be to get a total line count, but then i thought maybe i just need to search for a specific text, and now i'm wondering if its just an international vs US shipping address format and i build a split?

Thoughts, comments help is apprecia

 

 

 

  • Verified answer
    DexPoint Profile Picture
    114 on at
    Re: flow reading email body, adjust for more or less data

    This is for everyone to know what i did. 

    I created a new compose function that counts the number of items in the array. in this case i know the last portions of the email are always the same.

    Compose function

    length(outputs('splitEmail')

     

    then did another compose function to subtract the lines at end

    Compose2 function

    Add(output('compose'), -4)

     

    then in the clin line split i added the outputs from compose2

     

    Split(outputs('SplitEmail')[outputs('Compose2')], ' ')

     

    i'll watch and monitor this to see if its always constant. otherwise i can always remove the "" at the end of the array. but if it always comes in then i'll leave it as long as it calculates correctly.

  • DexPoint Profile Picture
    114 on at
    Re: flow reading email body, adjust for more or less data

    Actually the last line is a total line. here is what an actual email looks like. sometimes a contact phone appears in the address. sometimes its an additional address line to represent a building etc.

     

    MIME-Version: 1.0

    Content-Type: text/plain

     

    Authorization Date      PO Number         

    ----------------------  --------------------------

    06/07/2023              abcdefghijklmnopqrstuvwxyz

     

    CUSTOMER INFORMATION

    ---------------------------

    Name:  (address name here removed for this post)

    Phone: ###-###-####

    Email: (Cust Email removed for post)

     

    SHIPPING INFORMATION

    ---------------------------

    DODAAC: (ABC123 - removed for post)

    abc123  ## AA AAAA

     

    ### Street  BLDG 13850

    CP ### ### #### (Contact Phone, sometimes appears or doesnt)

    City, ST ZIPCODE

    US

     

    MARK FOR INFORMATION

    ---------------------------

    TCN: AA#### #### ####

    DODAAC: ABC123

    ABC123  ## AA AAAA

     

    ### Street  BLDG 13850

    CP ### ### #### (Contact Phone, sometimes appears or doesnt)

    City, ST ZIPCODE

    US

    CLIN  REQUISITION #        PRODUCT #          PRODUCT NAME                    UOS   QTY  UNIT PRICE        EXT PRICE   REQUIRED DELIVERY DATE

     

         1    abc123 #### ####    Part           P.Desc                            PK       2         1,951.49         3,902.98  AUG 21 2023

     

    Order Total:  $3,902.98

  • ManishSolanki Profile Picture
    15,085 Super User 2025 Season 1 on at
    Re: flow reading email body, adjust for more or less data

    Hi @DexPoint 

     

    If CLIN details is always the last element after splitting, then you can use last() function. last() function will fetch the last element of an array without using indexer.

     

    If this helps, please remember to give a 👍 and accept my solution as it will help others in the future.

     

    Thanks

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

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard >