Send Message if Email Body Contains Specific Pattern - Plus Time Email Arrived?

Basically each morning I want to iterate through the first 10 emails in my inbox. If the body of any of the emails contains:

Project ‘20201234_5678’ deployment to Production done successfully. (the numbers will all be different each morning aside from ‘2020’, so I know I need to use RegEx to find that pattern.)

Then I want to send a message saying "this was successful, at [timestamp of when that email was sent]. Else - I want to send a different message.

How would I go about this? I’ve been trying all day but have been unsuccessful.

@Luecke_Anthony I don’t think you really need to use regex, Have you tried using Just " Project deployment to Production done successfully" in the Contains method and checked if it is evaluated to True?

1 Like

@supermanPunch Unfortunately I receive a lot of emails all saying “Project deployment to Production done successfully”…so I need to filter out the ones with that number format in them “20201234_5678” where the numbers are dynamic each day (aside from ‘2020’).

Follow below steps-

  1. Read all the emails
  2. Loop through each email to check whether the deployment is successful. For each activity with the object property set to MailMessage.
  3. Use Regex IsMatch activity passing the email body in Input property and pattern property as
    “(Project [‘]+\d{8}_\d{4}[’] deployment to Production done successfully.)”
    Specify a boolean variable in Result property.
  4. If the result is true, Send message as
    "this was successful, at " + email.Headers(“Date”)
2 Likes

@Madhavi Ok so I can see that it is finding the match from the output shown.

image
But how do I only write line showing the match? I do not care about all the others. If I take this If activity outside the For Each loop, it only writes the Else write line. I know it is the 4th email by index in this case, but it will not always be the 4th, it will be random.

If match, do the needful operations within then block and then add break activity to stop processing.

1 Like

So would I need to adjust the workflow in my screenshot above? Or just add a break inside the “Then” box? Would I also add a break inside the “Else” box?

no add break inside then.

2 Likes

@Madhavi Great - I think I got it now. Thank you for all the help!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.