locked
Dynamic Mail flow rule RRS feed

  • Question

  • Hi everyone,

    I need to create a dynamic mail flow rule, the mail flow on exchange works by entering some keywords, when they found a mail will be redirected to someone else for example. now, the question is: Is there a way to make these word dynamic? I mean can the exchange grab these keywords from an external location (external SQL DB for example) when these words updated on the (external SQL) they should gets updated on the mail flow rule automatically. can that be achieved.

    In a brief, can the mail flow rule keywords gets updated when I update an external SQL table.

    Thanks. 


    • Edited by Venoux Thursday, October 31, 2019 6:11 AM
    Thursday, October 31, 2019 6:07 AM

Answers

  • Hi Mohamed Hsn,

    If your list of words, phrases, or patterns is long, you can put them in a text file with each word, phrase, or pattern on its own line. Use PowerShell to read in the list of keywords into a variable, create a mail flow rule, and assign the variable with the keywords to the mail flow rule condition.

    $Keywords=Get-Content "C:\My Documents\tmp.txt"
    New-TransportRule -Name "Block messages with unacceptable words" -SubjectOrBodyContainsWords $Keywords -SentToScope "NotInOrganization" -RejectMessageReasonText "xxxxx" 

    Regards,

    Beverly Gao


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

    • Proposed as answer by m.hassan.dayem Wednesday, November 6, 2019 6:30 PM
    • Marked as answer by Venoux Wednesday, November 6, 2019 6:37 PM
    Wednesday, November 6, 2019 9:33 AM

All replies

  • Hi Mohamed Hsn,

    You can configure your keywords through the content of a SQL table. But you have to run Set-TransportRule everytime you made changes on your SQL table to get the transport rule updated. The mail flow rule won't update automatically when you update your external SQL table.

    Regards,

    Beverly Gao


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


    Friday, November 1, 2019 7:13 AM
  • Hi Beverly, can you please redirect me to an example or how to do it, I can't found it online. 
    Friday, November 1, 2019 11:31 AM
  • Hi Mohamed Hsn,

    If your list of words, phrases, or patterns is long, you can put them in a text file with each word, phrase, or pattern on its own line. Use PowerShell to read in the list of keywords into a variable, create a mail flow rule, and assign the variable with the keywords to the mail flow rule condition.

    $Keywords=Get-Content "C:\My Documents\tmp.txt"
    New-TransportRule -Name "Block messages with unacceptable words" -SubjectOrBodyContainsWords $Keywords -SentToScope "NotInOrganization" -RejectMessageReasonText "xxxxx" 

    Regards,

    Beverly Gao


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

    • Proposed as answer by m.hassan.dayem Wednesday, November 6, 2019 6:30 PM
    • Marked as answer by Venoux Wednesday, November 6, 2019 6:37 PM
    Wednesday, November 6, 2019 9:33 AM
  • Thanks so much  Beverly Gao
    Wednesday, November 6, 2019 6:31 PM