0

I am trying to create a Transport rule to automatically add the shared email address when received after hours (8am-5pm).

The current idea is to use the "when the message header matches text patterns" condition on the "Received" header to detect if the email was received using hour values.

Received Header example:

 from mail.test.com (0.0.0.0) by
 mail.local.host.com (0.0.0.0) with Microsoft SMTP Server (TLS) id
 14.1.438.0; Thu, 11 Apr 2019 05:07:44 -0500

After Hour Patterns:

; (Mon|Tue|Wed|Thu|Fri), (\d|\d\d) \w\w\w 20\d\d (00|01|02|03|04|05|06|07|17|18|19|20|21|22|23):\d\d:\d\d -05
; (Sat|Sun), (\d|\d\d) \w\w\w 20\d\d \d\d:\d\d:\d\d -05

RegExr Link-Received After Hours

I thought the above patterns were working, but the next morning the shared email address was still being added to the emails and I am not sure why. I do know it seems that certain patterns don't seem to be supported. I did limit myself to this documentation:Regular Expressions in Transport Rules. There also seems to be a 128 character limit for the pattern.

Any help would be appreciated.

Nato
  • 101

2 Answers2

0

Is that your whole regex? Because it will match any date in the header.

I suggest you take the entire header of the email that got through, and paste it in to https://regex101.com/ along with your regex to see what it's matching on.

longneck
  • 23,082
  • 4
  • 52
  • 86
  • I have tried searching the entire header and the pattern isn;t matching on anything. Each line is a different pattern entered (one for Week days and one for weekends. Originally I had entered the exchange server information to limit it to capture the Received header for but this proved to be too large at the time. However I did do some minimizing since. I actually added the offset to only look for -05 because if its the same offset all should be good. Thinking about adding "-0(5|6)" for DST – Nato Apr 11 '19 at 20:19
  • I think you may check the received message header, I checked some of my received messages, and they are like: 11:00:53 +0800 or 01:46:30 +0000. It may be not always -05. – Shaw Lu Apr 12 '19 at 08:27
  • I checked several messages going back several years and the last received header always showed the local offset of our email server. – Nato Apr 15 '19 at 23:10
0

I think it may try in another way, try to run a task schedule to enable the rule after working time. Here is a reference.

Shaw Lu
  • 339
  • 1
  • 4