cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JamesWaugh
New Member

Sending email with specific subject

Hi all, I am new to power automate as its not something we as a company have needed until now. I am learning it as i go but i am stuck on how to do something and hoping someone can help.

 

I have set up a flow that checks emails as they arrive as we get them from several locations and cant alter the subject but all the emails contain the company name within the subject, the flow looks in the subject for certain  words, then if one of the words appears it sends an email, I send the email with a specific subject and add the subject and body of the original email to the new email (this is a ticketing email account so emails with the Subject of the company get a ticket created automatically hence why i am doing this). If one of those words is not there then a false statement checks for another set of words and does the exact same same and so on and so on until its finished checking.

 

Now i have to do this 30+ times (so check for each company we support) see image below for example of how i am currently doing this

 

flow1.png

 

What i would like to do is  put all the different words into one contains list and then send a new email with the subject of the name it finds from the contains list.

 

I can do the contains list and i can do the body of the email but getting the subject to be the name of the company it finds from the contains list seems to be failing me and cant see a way to do it.

 

Any help would be appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
efialttes
Super User
Super User

Hi!

Havent tested myself, but maybe you can add all patterns (i.e. words) in an array variable:

Add an Initialize variable action block, let's call the variable myPatternDictionary, type array, value:

 

[
"word1",
"word2",
"word3"
]

 

 So in the example I am searching for 3 patterns (word1, word2, word3), but you can add any number you need

NExt, add a 'Filter array' action block, assign as its input 'myPatternDictionar' variable. Now on the left side of its condition rule, add 'Subject' from the dynamic content menu. SElect operator 'contains'. On the right side of its condition rule, add the following expression:

 

item()

 

 

Next add a Condition action block, on the left side of its condition rule, add the following expression:

 

length(body('Filter_array'))

 

SElect 'greater than' as operator

Now, on the right side of its condition rule, add the following value

 

0

 

Flow execution will take the true branch if any of the patterns is found in the Subject... so on the true branch you should add the notification logic.

 

Please also note 'Filter array' output is an array also, with as many alements as patterns found in the subject. Assuming you can find either 0 or 1 pattern max., you can get the first pattern foundin the Subject  by means of the following expression:

first(body('FilterArray'))

 

If you are not familiar with expressions, please follow these steps to add them:

https://flow.microsoft.com/es-es/blog/use-expressions-in-actions/

Hope this makes sense

 



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



View solution in original post

3 REPLIES 3
efialttes
Super User
Super User

Hi!

Havent tested myself, but maybe you can add all patterns (i.e. words) in an array variable:

Add an Initialize variable action block, let's call the variable myPatternDictionary, type array, value:

 

[
"word1",
"word2",
"word3"
]

 

 So in the example I am searching for 3 patterns (word1, word2, word3), but you can add any number you need

NExt, add a 'Filter array' action block, assign as its input 'myPatternDictionar' variable. Now on the left side of its condition rule, add 'Subject' from the dynamic content menu. SElect operator 'contains'. On the right side of its condition rule, add the following expression:

 

item()

 

 

Next add a Condition action block, on the left side of its condition rule, add the following expression:

 

length(body('Filter_array'))

 

SElect 'greater than' as operator

Now, on the right side of its condition rule, add the following value

 

0

 

Flow execution will take the true branch if any of the patterns is found in the Subject... so on the true branch you should add the notification logic.

 

Please also note 'Filter array' output is an array also, with as many alements as patterns found in the subject. Assuming you can find either 0 or 1 pattern max., you can get the first pattern foundin the Subject  by means of the following expression:

first(body('FilterArray'))

 

If you are not familiar with expressions, please follow these steps to add them:

https://flow.microsoft.com/es-es/blog/use-expressions-in-actions/

Hope this makes sense

 



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



v-alzhan-msft
Community Support
Community Support

Hi @JamesWaugh ,

 

If one Condition would only check one value, and the value would be the subject or the new email, your requirement could be achieves with the containlist.

However, since each condition on your side would check 2 or 3 values, I think it couldn't be achieved with the containlist.

 

Best regards,

Alice   

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

 

Thanks for that, all working perfectly and doing as it should. I will no doubt be looking at upgrading this in the future but for now its working as we need it. Thanks again.

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (5,207)