How to Configure a New Transport Rule for Messages That Have a Blank Subject
Microsoft Exchange Server 2007 will reach end of support on April 11, 2017. To stay supported, you will need to upgrade. For more information, see Resources to help you upgrade your Office 2007 servers and clients.
Applies to: Exchange Server 2007, Exchange Server 2007 SP1, Exchange Server 2007 SP2, Exchange Server 2007 SP3
This topic explains how to use the Exchange Management Console or the Exchange Management Shell to configure a transport rule to perform an action on an e-mail message that has a blank subject line. This procedure can be used on computers that have the Hub Transport server role or the Edge Transport server role installed.
Before You Begin
To create a new transport rule to perform an action on an e-mail message that has a blank subject line, you use the same procedure that you use to create a new transport rule. Transport rule actions are available on Hub Transport servers and Edge Transport servers. You use these actions modify the delivery or contents of messages that meet the conditions you specify.
For more information about transport rules, see Overview of Transport Rules.
To perform the following procedures, the account you use must be delegated the following:
- Exchange Organization Administrator role
To perform the following procedures on a computer that has the Edge Transport server role installed, you must log on by using an account that is a member of the local Administrators group on that computer.
For more information about permissions, delegating roles, and the rights that are required to administer Microsoft Exchange Server 2007, see Permission Considerations.
Warning
This topic describes how to create new transport rules. Before you configure new transport rules in your production environment, use a test environment to learn how to create new transport rules and test them thoroughly. The following procedures are not intended to be run in a production environment without modification to support your organization.
Important
For transport rules to be applied to e-mail messages, a route must exist that enables the message to enter and leave a server that applies transport rules. Also, the message must not be subject to an administrator-configured transport restriction that prevents delivery of the message. If a transport restriction prevents delivery of a message, the Transport Rules agent cannot act on that message, and no Transport Rules agent events are logged.
The ^$ Regular Expression
To detect messages that have blank subject lines, the following procedures use the ^$
regular expression. This regular expression consists of two pattern strings, ^
and $
. Pattern strings are used in regular expressions to match patterns in the text of a message when that text changes dynamically. When the ^
and $
pattern strings are used in this order, the transport rule condition matches only the exact string that is between the two pattern strings. Because there is no string between the ^
and $
pattern strings in the ^$
regular expression, this regular expression matches only an empty string, such as a blank subject line.
For more information about regular expressions, see Regular Expressions in Transport Rules.
Using the Exchange Management Console to Create a New Transport Rule for Messages that Have a Blank Subject Line
The following procedures show you how to open the Transport Rule wizard on a Hub Transport server or an Edge Transport server in the Exchange Management Console, and then create a new transport rule to perform an action on an e-mail message that has a blank subject line. After you open the Transport Rule wizard, the procedure is the same on the Hub Transport server and the Edge Transport server.
To open the Transport Rule wizard in the Exchange Management Console on a Hub Transport server
Open the Exchange Management Console on the Hub Transport server.
In the console tree, click Organization Configuration, and then click Hub Transport.
In the result pane, click the Transport Rules tab, and then in the action pane, click New Transport Rule… .
To open the Transport Rule wizard in the Exchange Management Console on an Edge Transport server
Open the Exchange Management Console on the Edge Transport server on which you want to create the new transport rule.
In the console tree, click Edge Transport.
In the result pane, click the Transport Rules tab, and then in the action pane, click New Transport Rule… .
To use the Exchange Management Console to create a new transport rule for messages that have a blank subject line in the Transport Rule wizard
In the Name field of the Transport Rule wizard, type the name of the transport rule.
If you have notes for this rule, in the Comments field, type the notes.
If you want the rule to be created in a disabled state, clear the Enabled check box. Otherwise, leave the Enabled check box selected.
Click Next.
In the Step 1. Select Condition(s) box, select the when the Subject field contains text patterns condition.
In the Step 2. Edit the rule description (click an underlined value) box, click the text patterns blue underlined words.
When you click the text patterns blue underlined words, a new window opens to prompt you for the values to apply to the condition. Type ^$ and then click Add. Click OK to close the window and then click Next.
In the Step 1. Select Action(s) box, select all the actions that you want to be applied to this rule.
In the Step 2. Edit the rule description (click an underlined value) box, click each blue underlined word.
In the new window that appears, select the items that you want to apply, or type the values manually, and then click OK to close the window.
Repeat the previous step for each action that you selected. After you configure all the actions, click Next.
In the Step 1. Select Exception(s) box, select all the exceptions that you want to be applied to this rule. You are not required to select any exceptions.
If you selected exceptions in the previous step, in the Step 2. Edit the rule description (click an underlined value) box, click each blue underlined word.
When you click a blue underlined word, a new window opens to prompt you to select the items that you want to add, or to type the values manually. When you have finished, click OK to close the window.
Repeat the previous step for each exception that you selected. After you configure all the exceptions, click Next.
Review the Configuration Summary. If you are happy with the configuration of the new rule, click New, and then click Finish.
Using the Exchange Management Shell to Create a New Transport Rule for Messages that Have a Blank Subject Line
To use the Exchange Management Shell to create a new transport rule that applies a transport rule action to messages that have a blank subject line, see the "Using the Exchange Management Shell to Create a Transport Rule" section in How to Create a New Transport Rule.
Adding the Blank Subject Line Condition
The following procedure shows how you can add a transport rule condition to detect messages that have a blank subject line and apply an action to those messages.
To use the Exchange Management Shell to detect messages that have a blank subject line
Run the following commands:
$Condition = Get-TransportRulePredicate SubjectMatches $Condition.Patterns = @("^$")
Configuring the Blank Subject Line Action
After you have added the blank subject line condition, add the transport rule action that you want to perform on messages that match the condition. For example, you may want to reject the message and send a customized non-delivery report (NDR). In this topic, the RejectMessage
transport rule action is used to reject a message with an NDR. The RejectMessage
transport rule action exists on the Hub Transport server role.
To use the Exchange Management Shell to select the RejectMessage transport rule action
Run the following command:
$Action = Get-TransportRuleAction RejectMessage
You can modify the text that is displayed to the sender in the Diagnostic information for administrators section of the NDR. This text can provide helpful information to enable the administrator to understand why the message was rejected.
To use the Exchange Management Shell to configure the "Diagnostic information for administrators" text that appears in the NDR on a Hub Transport server
Run the following command:
$Action.RejectReason = "Sample reject reason"
You can also modify the delivery status notification (DSN) code and message that appears in the user information section of the NDR by specifying a customized DSN code. A customized DSN code is associated with a customized DSN message. It is useful to specify this code so that you can refer the user to an HTML link to a specific policy or regulation. By default, the NDR associated with the 5.7.1 DSN code is sent.
For example, if you create a new transport rule for messages that have a blank subject line and want to refer users to the Information Technology department if their message is rejected, you can specify a new, unused, customized DSN code in the EnhancedStatusCode property. After you specify a new customized DSN code, you must use the New-SystemMessage cmdlet to create the DSN code and specify the text that should be displayed when that DSN code is referenced. For an example of how to do this, see the "Configuring a Transport Rule that Rejects Messages that Have a Blank Subject" section later in this topic.
Note
The RejectReason
transport rule action is available only on Hub Transport servers. If you want to reject messages that have a blank subject line on Edge Transport servers, you must use the SmtpRejectMessage
transport rule action. You can only specify the DSN code when you use the SmtpRejectMessage
transport rule action. You cannot specify an alternative message to display to the user or administrator.
For more information about the SmtpRejectMessage
transport rule action, see the "Supported Actions on an Edge Transport Server" section in Transport Rule Actions.
For more information about what values are accepted and how Exchange 2007 associates a DSN code with a transport rule, see Associating a DSN Message with a Transport Rule.
To use the Exchange Management Shell to configure the user information text in an NDR by specifying a customized DSN code on a Hub Transport server
Run the following command:
$Action.EnhancedStatusCode = "5.7.228"
For more information about these action properties, see Transport Rule Actions.
Creating the New Transport Rule for Messages that Have a Blank Subject Line
After you configure the conditions, exceptions, and actions, create the new transport rule that enforces the transport rule.
To use the Exchange Management Shell to create a new transport rule that rejects messages that have a blank subject
Run the following command:
New-TransportRule -Name "Sample Blank Subject Transport Rule" -Condition @($Condition) -Action @($Action)
Configuring a Transport Rule that Rejects Messages that Have a Blank Subject
The following example shows how you can apply a transport rule that rejects messages that have a blank subject on a Hub Transport server.
Note
This transport rule uses a customized DSN code and message. The New-SystemMessage command in this example creates the customized DSN code and message. For more information, see Associating a DSN Message with a Transport Rule.
To use the Exchange Management Shell to configure a transport rule that rejects messages that have a blank subject on a Hub Transport server
Run the following commands:
$Condition = Get-TransportRulePredicate SubjectMatches $Condition.Patterns = @("^$") $Action = Get-TransportRuleAction RejectMessage $Action.RejectReason = "Messages must have a subject in the subject line or they are rejected." $Action.EnhancedStatusCode = "5.7.228" New-SystemMessage -DsnCode 5.7.228 -Internal $True -Language En -Text "This message was rejected because it did not have a subject in the subject line. For more information, please contact the Information Technology department." New-TransportRule "Blank Subject Transport Rule" -Condition @($Condition) -Action @($Action)
For More Information
For detailed syntax and parameter information about each command, see the following topics:
For more information about transport rules, see the following topics: