cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dbugden
Level: Powered On

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

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!

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

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

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,

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

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

Hi @dbugden ,

 

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

 

Best Regards,

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

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

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,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
dbugden
Level: Powered On

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

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

 

Appreciate your help!

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020.

thirdimage

Flow Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Flow Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 241 members 4,356 guests
Please welcome our newest community members: