Skip to main content

Notifications

Community site session details

Community site session details

Session Id : 6sZmv0jBzp7YBTUqSzg/5C
Power Automate - Building Flows
Unanswered

dynamic values emailtemplate returns error null values

Like (1) ShareShare
ReportReport
Posted on 2 Jul 2024 18:19:36 by 2,237

Basically, im comparing the list email templates with incoming email and if its matches then it parses metadata as per below flow ,but issue even my incoming email is in proper format as per email template sharepoint list it returns no matches.

 

Veblitz_0-1719943863768.png

Incoming email

 

Veblitz_3-1719944277739.png

 

Flow

 

Veblitz_1-1719944000404.png

 

Veblitz_2-1719944032004.png

 

 

  • Veblitz Profile Picture
    2,237 on 07 Jul 2024 at 09:07:09
    Re: dynamic values emailtemplate returns error null values

    Many thanks for your great help. Much appreciated 

  • Nived_Nambiar Profile Picture
    17,340 Super User 2025 Season 1 on 03 Jul 2024 at 18:43:56
    Re: dynamic values emailtemplate returns error null values

    Hi @Veblitz 

     

    There is way to do with regular expression, so few changes need to be made.

     

    I am assuming your email format looks like this

    Nived_Nambiar_1-1720031114600.png

     

    Now in the sharepoint list- i have set the subject and content pattern like this

    Nived_Nambiar_2-1720031163697.png

     

    I am using a regular pattern here for mail and subject. Also i hav excluded extra lines that comes in email body as it may be sometimes more lines coming up than expected, i have made the flow to remove the empty lines so that content looks exactly as per the pattern shown above

     

    Email subject

     

     

     

     

     

    Contractor Request- [A-Za-z]+

     

     

     

     

     

     

    Email body

     

     

     

     

     

    Hi [A-Za-z]+,
    Please find the details below
    Title: [A-Za-z]+
    Location: [A-Za-z]+
    Note: This email is autogenerated. Do not reply to this email.
    Thanks,
    Support Team

     

     

     

     

     

     

     

    Now create an office script in excel file which helps to validate the email subject & body patterns using regex.

    For that create an excel file and then write the following office script 

     

     

    Nived_Nambiar_15-1720032701041.png

     

    Nived_Nambiar_3-1720031526876.png

     

    Now coming to the flow

     

    1. Use trigger when email arrives which triggers the process when email arrives in Inbox.

    2. Now will get the patterns details from list - workload in which i have stored the email pattern details

    Nived_Nambiar_4-1720031550704.png

     

    3. Convert the email body to plain text format as shown below

    Nived_Nambiar_5-1720031614516.png

     

    4. Loop through output of get items action like below

    Nived_Nambiar_6-1720031649323.png

     

    Inside the loop - do the following

    4.1- Use the filter array to remove empty new lines in email body like below

    Nived_Nambiar_7-1720031710032.png

     

    Expression used- 

    split(outputs('Html_to_text')?['body'],decodeUriComponent('%0A'))
    Nived_Nambiar_8-1720031738849.png

     

    Expression - 

    or(equals(item(), null), empty(trim(item())))
     
    4.2- use the run script action which helps to run an office script to check whether the email subject or email body matches the pattern stored in the SharePoint list like below.
    Nived_Nambiar_9-1720031841669.png

     

    Top fields SubValue represent subject of email, and SubPattern represent the subject pattern stored in sharepoint list.

    For the flag - put gm as value.

     

    Nived_Nambiar_12-1720032011690.png

     

    for the BodyVal use this expression - 

    join(body('Filter_array'),decodeUriComponent('%0A'))
     
    for the bodypattern, use this expression
    Nived_Nambiar_11-1720031974358.png

     

    Expression - 

    replace(items('Apply_to_each')?['Content'],'\\n','[\n]+')
     
    Now using the output of run script you can validate whether the email subject or email body matches 
    In condition, as shown - this is used to validate the email subject part
    Nived_Nambiar_13-1720032122101.png

     

    Expression - 

    first(outputs('Run_script')?['body/result'])
     
    Second row of condition checks for email body validation
    Nived_Nambiar_14-1720032167218.png

     

    Expression - 

    last(outputs('Run_script')?['body/result'])
     
     
    if both values are matching- then you can say that email template matches
     
    This is just a sample flow to show how you can do this. You can change the code depending on your logic.
     
    Thanks & Regards,

    Nived N 🚀

    LinkedIn: Nived N's LinkedIn
    YouTube: Nived N's YouTube Channel
    Blog: Nived Nambiar's Blogs

    🔍 Found my answer helpful? Please consider marking it as the solution!
    Your appreciation keeps me motivated. Thank you! 🙌


     

     

  • Veblitz Profile Picture
    2,237 on 02 Jul 2024 at 19:23:18
    Re: dynamic values emailtemplate returns error null values

    i have no idea about comparing and please help me how to check the same. Thanks

  • Nived_Nambiar Profile Picture
    17,340 Super User 2025 Season 1 on 02 Jul 2024 at 19:10:52
    Re: dynamic values emailtemplate returns error null values

    Hi @Veblitz 

     

    How you are comparing the given subject pattern in list with trigger email subject using eq operator?

    same for email body as well. 

     

    Along with that i see you have used && in odata filter query, i think you should use and instead.

    Nived_Nambiar_0-1719947446252.png

     

    Thanks & Regards,

    Nived N 🚀

    LinkedIn: Nived N's LinkedIn
    YouTube: Nived N's YouTube Channel
    Blog: Nived Nambiar's Blogs

    🔍 Found my answer helpful? Please consider marking it as the solution!
    Your appreciation keeps me motivated. Thank you! 🙌

     

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

Thomas Rice – Community Spotlight

We are honored to recognize Thomas Rice as our March 2025 Community…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,508 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,369 Most Valuable Professional

Leaderboard
Loading started