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 / Condition based on sub...
Power Automate
Answered

Condition based on subject contents with auto reply to sender if not met.

(0) ShareShare
ReportReport
Posted on by 8

I'm quite new to this.

I'd like to create a condition based on the contents of the mail subject when extracting attachements from email.

I need the following to be done (if possible).

The email subject must start with the following string "PL ###-#### ####" all mails must start with PL, the # indicates a number that is variable from mail to mail but it must be in this exact format.

 

e.g "PL 111-2222 3333" or "PL 555-1234 8974"

 

If the condition is not met i'd like the flow to give an auto reply to the sender.

Categories:
I have the same question (0)
  • ChristianAbata Profile Picture
    8,951 Most Valuable Professional on at

    hi @Torgil  pleasee see this is what you need

     

    condition.PNG

     

    I add inside compose action your email subject then I get the lenght to see if some users sends you a code with less numbers as the correct format then send email or if don't contains PL send email.

     

    Hope you this helps you.

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

    Hi @Torgil ,

     

    Please refer to screenshot below to create the flow with Condition:

    1.png

     

    The expression in the Compose 2 as below:

    string('PL ')

    The expression in the Compose 3 as below:

     

    substring(outputs('Compose'),6,7)

     

     

    The expression in the Compose 4 as below:

     

    string('-')

     

     

    The expression in the Compose 5 as below:

     

    substring(outputs('Compose'),11,1)

     

     

    The expression in the Compose 6 as below:

     

    string(' ')

     

     

     

    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.

     

     

  • Torgil Profile Picture
    8 on at

    Hi @v-alzhan-msft 

    Thank you for the help this seems to work with one exception.

    When the subject of the mail contains less than 12 "characters" the flow will stop on and generate an error.

     

    It stops on either compose 3 or compose 5 depending on how many characters the subject of the mail consists of.

     

    This is the error code:

    InvalidTemplate. Unable to process template language expressions in action 'Compose_3' inputs at line '1' and column '21541': 'The template language function 'substring' parameter is out of range: 'start index' must be non-negative integer and should be less than the length of the string. Please see https://aka.ms/logicexpressions#substring for usage details.'.

     

    Do you have a way to correct this issue?

     

    And again many thanks so far.

     

     

    Torgil 

     

     

     

  • v-alzhan-msft Profile Picture
    on at

    Hi @Torgil ,

     

    Sorry for the solution would only work for PL 111-2222 3333 that you shared has 16 characters.

     

    If sometime don't have 16 character, you could delete the special part.

     

    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.

  • Torgil Profile Picture
    8 on at

    Hi again @v-alzhan-msft 

     

    Not quite sure what you mean with deleting of the special part?

     

    Kind Regards

    Torgil

  • v-alzhan-msft Profile Picture
    on at

    Hi @Torgil ,

     

    I means you only check if the subject start with PL .

     

    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.

  • Torgil Profile Picture
    8 on at

    Hi @v-alzhan-msft 

     

    Ok, then i think that the first example will work better for me. As it normally shouldn't be a problem.

    There's no way around to solve this in other ways?

     

    Again very much thanks for the help, it provided me with a lot better understanding on how this works.

     

    Kind Regards

    Torgil

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

#2
Tomac Profile Picture

Tomac 324 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard