Is there a way using VBA to have OUTLOOK delete any incoming email that meet 2 conditions below.


Condition #1

The body of the email must contain the following text string with variable date and time:


Transaction Date: XX/XX/XXXX XX:XX:XX AM/PM


Where XX/XX/XXXX is the date written in the following format: m/d/yyyy and time is 12hr time in the following format h:mm:ss AM/PM


Here is the string with a date and time as an example


Transaction Date: 9/21/2021 2:13:01 PM


Note: The body of the email contains other lines of text both before and after this specific string.


Condition #2


The date and time shown in the Transaction Date line is no more than 15 minutes from the date/time the email was received (based on the time stamp of the email).
For example, an email with time stamp 10/21/2021 1:42PM and containing the string below in the body would not be deleted


Transaction Date: 10/21/2021 1:38:13 PM


If it was any other date however, or the time was >15mins it would be deleted, like these 2:


Transaction Date: 10/21/2021 11:01:20 AM


Or


Transaction Date: 9/3/2021 1:44:01 PM



If this VBA code is possible, could it instead move the email to a folder named Old Transactions? If so, what would that code look like?

Also, how would the code change if it only needed to be run to delete/move already received emails?


Thank you to anyone that can help