none
Transport Rules and regex NOT operator

    问题

  • Hello all,

    I'm trying to create a transport rule that basically adds some text to the subject line if the from address is NOT in a particular list of domains, however I can't seem to find any documentation that Exchange transport regex support the NOT operator. So far I've tried it with one domain:

    ^((?!mydomain.com).)*$

    with the intention being that if the message doesn't come from mydomain.com then it'll have some text prepended to the subject, however this doesn't work. 

    Does Exchange transport regex support the NOT operator and if it does can anyone help explain how to use it?

    2018年7月3日 10:42

全部回复

  • Hi,

    To exclude the domain in transport rule, we can add an exception to bypass some special domain. For example:

    For regular expression in transport rule, you can view the available Pattern strings in Regular Expressions in Transport Rules.

    Best Regards,
    Allen Wang


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.


    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    2018年7月4日 8:33
    版主
  • Thanks Allen, I can't see the picture you've embedded in your reply, I've tried different browsers but its just not appearing.
    2018年7月4日 9:30
  • How about try it by IE, and check it by private mode?

    Best Regards,
    Allen Wang


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.


    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    2018年7月5日 3:49
    版主
  • Hello Allen, I've just tried that, all I'm seeing is a black and white 'X' where the picture should be - can you just describe the rule to me?
    2018年7月5日 10:08
  • All right, when we create a transport rule, we can add a exception to exclude specific messages from the transport rule action.

    In current situation, the condition is "Apply to all messages", you can add an exception like "The Sender's domain is 'Your domain'".

    Best Regards,
    Allen Wang


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.


    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    2018年7月6日 1:50
    版主
  • Thanks Allen, I did originally try "except when the message is form from users that are inside the organisation" however in my case this won't work - we are two companies that share an SMTP namespace but our Exchange organisations are separate - so if user1@mydomain.com in the other company sends a message to me@mydomain.com, my Exchange environment still sees it as an external e-mail because user1@mydomain.com has not authenticated against my Exchange environment.

    Hence why I was trying to use regex with the NOT operator to exclude @mydomain.com

    2018年7月6日 9:23
  • Thanks for your update.

    We can use "The Sender's domain is 'Your domain'" as exception, all messages send from ”your domain“ will not trigger this rule.

    Best Regards,
    Allen Wang


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.


    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    2018年7月10日 2:07
    版主
  • Thanks for getting back to me Allen - 'The senders domain is....' does not exist in my exclusion list:

    Get-TransportRule | select except*

    ExceptIfFrom
    ExceptIfFromMemberOf
    ExceptIfFromScope
    ExceptIfSentTo
    ExceptIfSentToMemberOf
    ExceptIfSentToScope
    ExceptIfBetweenMemberOf1
    ExceptIfBetweenMemberOf2
    ExceptIfManagerAddresses
    ExceptIfManagerForEvaluatedUser
    ExceptIfSenderManagementRelationship
    ExceptIfADComparisonAttribute
    ExceptIfADComparisonOperator
    ExceptIfSenderADAttributeContainsWords
    ExceptIfSenderADAttributeMatchesPatterns
    ExceptIfRecipientADAttributeContainsWords
    ExceptIfRecipientADAttributeMatchesPatterns
    ExceptIfAnyOfToHeader
    ExceptIfAnyOfToHeaderMemberOf
    ExceptIfAnyOfCcHeader
    ExceptIfAnyOfCcHeaderMemberOf
    ExceptIfAnyOfToCcHeader
    ExceptIfAnyOfToCcHeaderMemberOf
    ExceptIfHasClassification
    ExceptIfHasNoClassification
    ExceptIfSubjectContainsWords
    ExceptIfSubjectOrBodyContainsWords
    ExceptIfHeaderContainsMessageHeader
    ExceptIfHeaderContainsWords
    ExceptIfFromAddressContainsWords
    ExceptIfSubjectMatchesPatterns
    ExceptIfSubjectOrBodyMatchesPatterns
    ExceptIfHeaderMatchesMessageHeader
    ExceptIfHeaderMatchesPatterns
    ExceptIfFromAddressMatchesPatterns
    ExceptIfAttachmentNameMatchesPatterns
    ExceptIfSCLOver
    ExceptIfAttachmentSizeOver
    ExceptIfWithImportance
    ExceptIfMessageTypeMatches
    ExceptIfRecipientAddressContainsWords
    ExceptIfRecipientAddressMatchesPatterns
    ExceptIfSenderInRecipientList
    ExceptIfRecipientInSenderList
    ExceptIfAttachmentContainsWords
    ExceptIfAttachmentMatchesPatterns
    ExceptIfAttachmentIsUnsupported
    ExceptIfAnyOfRecipientAddressContainsWords
    ExceptIfAnyOfRecipientAddressMatchesPatterns

    2018年7月10日 10:17
  • Enn.... Sorry, it's in Exchange 2013.
    However, your environment is Exchange 2010. :(

    Best Regards,
    Allen Wang


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.


    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    2018年7月11日 6:12
    版主
  • That's OK Allen, we may be able to implement this on our e-mail gateways instead; just out of curiosity though, can you confirm whether or not the regex NOT operator is supported? The documentation makes no mention of it: https://docs.microsoft.com/en-us/previous-versions/office/exchange-server-2010/aa997187(v=exchg.141)

    2018年7月11日 9:24
  • Hi,

    Sorry for the delay.

    According to my knowledge, the parameter ExceptIfSenderDomainIs is not supported in Exchange 2010, which should be a by-design behavior, we could conclude this from the following article: Mail flow rule conditions and exceptions (predicates) in Exchange 2016.

    Regards,

    Manu Meng


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.

    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    2018年7月25日 9:21
    版主