web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Parsing email from sha...
Power Automate
Unanswered

Parsing email from shared mailbox to SQL - can I use an array?

(0) ShareShare
ReportReport
Posted on by 5

Hi all,

 

I have created a Flow to parse a shared 'noreply' mailbox, looking for certain failed email deliveries and logging them.

 

I've used the 'When new email arrives in shared mailbox' as my trigger, then Get Email from there.  Each email body and subject are parsed in parallel (after converting to text) to produce fields including personal data from the subject and the reason for the email delivery failure in the body.  This is all pushed into Excel and SQL for reporting later.

 

To parse each piece of info, I have created separate variables, using first/last expressions to grab the text in between, as the layout is almost always the same.

 

I was wondering if there is a better way to create my variables using an array to initialise the full email body, then parse that for each item?  I'm still a newbie, so there has been a bit of hacking going on... 😬

 

Here's the full Flow:

Full flow diagram

This is a slightly zoomed section:

Flow - zoomed in

This is the source email - I'm extracting the following fields from the subject:

Buy or Sell (SELL in this case)

Account number (123456)

Name (ABC SUPERANNUATION PTY LTD)

Contract (7654321)

 

And from the body:

Email (sample@abc.com.au)

Reason (554 5.4.7 [internal] exceeded max time without delivery)

 

Source email

These are the expressions used in the second screenshot above:

last(split(body('Convert_email_body_to_text'),'addresses: '))

 

first(split(variables('EmailRecipientPre'),'Reason: '))

 

It all seems pretty cumbersome as I have at least one, usually two variables created for each of the fields above. I'm hoping someone smarter than me can help suggest an array to achieve this?

 

Thank you!

 

Categories:
I have the same question (0)
  • v-bacao-msft Profile Picture
    on at

    Hi @dbugden ,

     

    You need to use two strings separately to get the middle specified part.

     

    Best Regards,

  • Verified answer
    v-bacao-msft Profile Picture
    on at

    Hi @dbugden ,

     

    Please refer to following expression:

    trim(first(split(last(split(body('Html_to_text'),'the following addresses:')),'Reason')))
    trim(first(split(last(split(body('Html_to_text'),'Reason:')),'The message subject was:')))

    Image reference:

    1.PNG

    2.PNG

    Hope it helps.

     

    Best Regards,

  • dbugden Profile Picture
    5 on at

    Thanks very much @v-bacao-msft , that simplifies my Flow a lot...

     

    Appreciate your help!

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard