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

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Challenges with @conta...
Power Automate
Answered

Challenges with @contains not working

(0) ShareShare
ReportReport
Posted on by 5

We have some wide ranging troubles with @contains not working when interrogating email sender and subject lines. Am interested (and would be very grateful) if anyone can spot the problems with these codes! 

 

Example in the case of email sender:

 

@contains(triggerBody()?['From'], 'my.name@my.company.com')

 

This does not =true when the sender's email address contains my.name. The only way we have found to get a condition to fire correctly is using @equals which limits things obviously.

 

Also... when trying to trap some different types of event using a nested if statement in a switch case 'On' box the following also does not work...

 

@if(contains(triggerBody()?['Subject'],'Alarm'),'AlarmCase',
if(contains(triggerBody()?['Subject'],'Warning'),'WarningCase',
if(contains(triggerBody()?['Subject'],'Test'),'TestCase','DefaultCase')
))

 

If the email subject contains the words 'Test' or 'Warning' or 'Alarm' this collection of @contains do not fire. We always default to the Default case. 

 

In short, it seems as if @contains simply doesn't work - which is unlikely, or the syntax is subtly wrong, or I'm missing a huge thing here. 

 

 

 

Categories:
I have the same question (0)
  • Verified answer
    v-yuazh-msft Profile Picture
    Microsoft Employee on at

    Hi @GrahamBristol,

     

    For your first question:

     

    I have made a test on my side and don't have the issue that you mnetioned.

     

    The expresion :

     

    @contains(triggerBody()?['From'], 'Test2@XXXX.onmicrosoft.com')

     

    Works fine on my side and a email is sent from the address "Test2@XXXX.onmicrosoft.com" ,

     

    Please check if the email is sent from the address my.name@my.company.com, the flow distinguish between uppercase and lowercase letters,please make sure the email is sent from the address my.name@my.company.com.

     

    For your second question:

     

    You should create a flow with expression as below:

    Capture.PNG

    The expression on the flow should as below:

    if(contains(triggerBody()?['Subject'],'Alarm'),'AlarmCase',if(contains(triggerBody()?['Subject'],'Warning'),'WarningCase',if(contains(triggerBody()?['Subject'],'Test'),'TestCase','DefaultCase')))
    

    Please make sure don't enter the expression in the On field directly.

     

    When the subject of the email is equal to Alarm,the flow would run successfully as below:

    Capture.PNG

     

    Best regards,

    Alice

  • GrahamBristol Profile Picture
    5 on at

    Dear Alice, 

     

    Thanks very much for your help! On point two, the requirement to add the 'if' in an expression window and not the 'On' box was not clear to me. I've done as you suggest and this works now - thank you. 

     

    I'm still having problems with the sender contains conditional flow but I will do some more investigating. 

     

    I believe that the behaviour of:

    @contains(triggerBody()?['From'], msflow.test')

    is different if the sender is msflow.test vs. msflow.test@mycompany.com. In my tests the flow does not fire when the sender is msflow.test however it does fire if the sender is msflow.test@mycompany.com. It seems as if the @contains(triggerBody()?['From'] part requires an abc@def.ghi format. Is that true? 

     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
trice602 Profile Picture

trice602 237 Super User 2026 Season 1

#2
David_MA Profile Picture

David_MA 173 Super User 2026 Season 1

#3
Kalathiya Profile Picture

Kalathiya 95 Super User 2026 Season 1

Last 30 days Overall leaderboard