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

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

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


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

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

4. Loop through output of get items action like below

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

Expression used-
split(outputs('Html_to_text')?['body'],decodeUriComponent('%0A'))
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.
Top fields SubValue represent subject of email, and SubPattern represent the subject pattern stored in sharepoint list.
For the flag - put gm as value.
for the BodyVal use this expression -
join(body('Filter_array'),decodeUriComponent('%0A'))
for the bodypattern, use this expression
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
Expression -
first(outputs('Run_script')?['body/result'])
Second row of condition checks for email body validation
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.