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 / check if outlook subje...
Power Automate
Answered

check if outlook subject is changed

(0) ShareShare
ReportReport
Posted on by

I'd like to add specific outlook messages to planner using power automate.

I want to check if the subject contains a specific string (I have a python script that changes the subject of the emails).

I want to know please if it possible to check if the subject of an email has changed?

 

Categories:
I have the same question (0)
  • DamoBird365 Profile Picture
    8,942 Microsoft Employee on at

    Hi @kfir1200 

     

    You need to decide how you Flow will triggers.  On a schedule and in which case you check the emails daily OR when an email is received?

     

    The get items action allows you to filter all emails in a inbox or folder within your Mailbox for subjects containing a string.

     

    DamoBird365_0-1616663354622.png

     

    You don't say how or when your python script runs and it's hard to know when or why you want to check the subject name changing.  You would need to create a history of the subject in order to do a comparison which could be achieved with a flow that logs the subject and details of the email as it is received allowing you to compare with a flow at a later date.

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
    Cheers,
    Damien


    P.S. take a look at my new blog here

     

     

  • Community Power Platform Member Profile Picture
    on at

    Hi @DamoBird365,

     

    Thanks for the reply.

     

    I want to check every hour if my subject contains "order" and "-".

     

    In the subject filter i need to write: "order" AND "-"?

     

    Also, i want to add the mail to planner, but i don't know how to check if the plan already exists (because my flow working on schedule i don't want to create duplicate plans in planner).

     

    I can't find how i can compare the task title with my  message subject. 

     

     

     

     

  • DamoBird365 Profile Picture
    8,942 Microsoft Employee on at

    Hi @kfir1200 

     

    With planner, you can use the action list my tasks or list tasks and perform a filter on the subject.  Then you would perform a condition action on the length('values from the get list tasks') gt 0. 

     

    WIth regards to search for two strings in the subject, I am not convinced it is possible from the get emails action.  You could filter on order and then perform a subsequent array filter action on the results where the subject contains -.

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
    Cheers,
    Damien


    P.S. take a look at my new blog here

     

     

  • Community Power Platform Member Profile Picture
    on at

    Hi @DamoBird365 ,

     

    This is my subject filter in get mails v3:

     

    @and(contains(triggerBody()?['Subject'],'order'),contains(triggerBody()?['Subject'],'-'))

     

    When I'm testing the flow I'm getting this error:

     

    InvalidTemplate. Unable to process template language expressions in action 'Get_emails_(V3)' inputs at line '1' and column '22115': 'The template language function 'contains' expects its first argument 'collection' to be a dictionary (object), an array or a string. The provided value is of type 'Null'.'.

     

    what is the problem?

  • DamoBird365 Profile Picture
    8,942 Microsoft Employee on at

    Hi @kfir1200 

     

    triggerBody()?['Subject'] is the data retrieved by your flow trigger and not the get items action.

     

    The subject filter is literally looking for a string, I am not convinced you can use an expression here but other members might know better.  Hence why I suggest that you filter on thes string order and then use a filter array action on subject contains -.

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
    Cheers,
    Damien


    P.S. take a look at my new blog here

  • Community Power Platform Member Profile Picture
    on at

    Hi @DamoBird365,

     

    My subject filter is: 

     

    string('-')

     

    and now it's working.


    I'm new to power automate and it's very different than Python so can you give me exmaple how i can check if the plan already exists using the subject of the plan?

     

    Thanks,

    Kfir

  • DamoBird365 Profile Picture
    8,942 Microsoft Employee on at

    Hi @kfir1200 

     

    I went with the following which is the reverse of my original suggestion as I couldn't work out how to filter an array on -.  But the gets emails will just return emails with - in subject before the filter on order.

     

    DamoBird365_0-1616683154105.png

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
    Cheers,
    Damien


    P.S. take a look at my new blog here

  • Community Power Platform Member Profile Picture
    on at

    Hi @DamoBird365,

     

    I want to know please if i can use a nested loops in power automate?

    I need to compare the subject of the email with the title of the plan in planner.

    I need to do something like that:

     

     

     

    int i=j=0;
    arr - an array of outlook messages
    arr1- an array of the tasks in planner
    for(i=0;i<arr.length();i++)
    {
     for(j=0;j<arr1.length();j++)
     if(arr1.subject != arr1.subject)
     do something..
    
    }

     

     

     

     

     

     

  • DamoBird365 Profile Picture
    8,942 Microsoft Employee on at

    Hi @kfir1200 

     

    That's just an apply to each inside an apply to each.  Both take the different values from the two data sources and the 2nd apply to each will compare the current item of the first apply to each with the current item of EACH of the apply to each items to give you the result.

     

    Not sure how efficient it would be but it would work.  If you are running this on large lists though I guess it would need tested to the extreme as you might end up with a timeout.

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
    Cheers,
    Damien


    P.S. take a look at my new blog here

  • Community Power Platform Member Profile Picture
    on at

    Hi @DamoBird365,

     

    thannks for the reply, I want to do something like this:

     

     

     

    int i=j=0;
    bool is_exists=false;
    arr - an array of outlook messages
    arr1- an array of the tasks in planner
    
    for(i=0;i<arr.length();i++)
    {
     for(j=0;j<arr1.length();j++)
    {
     if(arr.subject == arr1.subject)
     is_exists=true;
    }
     if(is_exists==false)
     create_planner_task();
    
     is_exists=false;
    }

     

     

     

    can i do this in power automate?

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 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard