Click here to monitor SSC
Av rating:
Total votes: 7
Total comments: 2


Ben Lye
Using Exchange 2007 Transport Rules to Protect the First Entry in the Address Book
08 June 2009

Global Address Lists in MS Exchange can cause problems because the first person in the list often gets the reply. Ben Lye shows how one can eliminate any such problems with Global Address lists by creating a mail contact, a transport rule and a custom Delivery Status Notification

I was recently asked to add an entry to the Outlook address book which would prevent mail being inadvertently sent to the person who normally appeared at the top of the Global Address List (GAL) – the person was getting frustrated by receiving e-mail which was clearly not intended for him.

There are several possible ways this could be achieved: a mailbox with an auto-reply or out-of-office rule, a public folder with an auto-response, a non-Exchange auto-responder, or simply a mail contact with an invalid external address, to name a few.


Fortunately, Exchange 2007
provides mechanisms
which can be used to
provide a neat solution
to this problem.
                     ”

Ideally I wanted the e-mail to be stopped on Exchange without requiring an extra mailbox or public folder, and I wanted the sender should get a helpful error message.  These requirements meant that a mailbox or public folder with an auto-reply rule could not be part of the ideal solutions, and neither could a non-Exchange auto-responder as that would mean that the email would have to leave the Exchange environment before being stopped.  Additionally, using a contact record with an invalid address was not perfect either; because a  user who e-mailed the contact  would simply receive a rather unhelpful ‘address unknown’ non-delivery report (NDR).

Fortunately Exchange 2007 provides mechanisms which can be used to provide a neat solution to this problem.  The solution has three parts: a mail contact which will appear at the top of the GAL, a transport rule to prevent mail being sent to the contact, and a custom delivery status notification (DSN) to provide the user with information about why their message was not delivered.

Mail Contacts are Active Directory objects which are typically used to add e-mail addresses which are external to Exchange 2007 to the Global Address List.  To create a new mail contact you must be delegated the Exchange Recipient Administrator role and the Account Operator role Active Directory container where you wish to create the contact.

Transport rules run on Exchange 2007 servers which have either the Hub Transport or Edge Transport role installed.  They can be used to control the flow of e-mail messages within the Exchange 2007 organization and can be used for a variety of purposes including for restricting e-mail between certain individuals or groups, or for applying a footer to all e-mail destined for Internet recipients. 


[Transport rules] can be
used to control the flow
of e-mail messages
within the Exchange
2007 organization...
                   ”

Custom DSN messages give Exchange 2007 administrators the facility to create new DSN messages for custom delivery notifications and the ability to customize existing DSN messages.  They are a useful tool if you wish to provide users with links to further information such as links to self-help knowledge base articles, or contact information for help-desk staff.

To create transport rules and custom DSN messages you must be delegated the Exchange Organization Administrator role.

The first step in implementing this solution is to create a new mail contact which has a display name that will ensure it is shown as the first entry in the GAL.  An easy way to do this is to prefix the display name with a period or underscore or any other valid character which does not normally appear in Exchange display names (spaces are prohibited as leading characters in display names).  We also need to specify an e-mail address which is not in use by another e-mail enabled object.

The mail contact can be created in the Exchange Management Shell using the New-MailContact cmdlet:

New-MailContact -Name ".First Address Book Entry" -ExternalEmailAddress
"firstaddressbookentry@example.com" -Alias "firstaddressbookentry"

New-MailContact cmdlet

The new mail contact will appear in the Outlook address book:

Outlook Address Book

The second step is to create a new custom delivery status notification (DSN) message which will be sent to anybody who e-mails the new mail contact.  Custom DSN messages can contain plain text or HTML, and in this case will provide useful information to the user pointing out that their message probably did not reach the intended recipient.

We’ll create a DSN message for DSN code 5.7.10, which is the first available enhanced status code (the valid range is 5.7.10 through 5.7.999 inclusive)

The Exchange Management Shell cmdlet for creating DSN messages is New-SystemMessage:

New-SystemMessage -DsnCode 5.7.10 -Text 'You have accidentally sent an e-mail to the first entry in the Outlook Global Address List.<br>You may wish to resend your message to the correct recipient.' -Internal $True -Language en

New-SystemMessage

The final step is to create a new transport rule which will send the new DSN message to anybody who e-mails the new mail contact.

Transport rules consist of three components: conditions, actions, and exclusions.  To create a new transport rule we must specify at minimum the action to be taken, but in this case we’ll specify a condition and an action.  The transport rule can be created in the Management Shell using these commands, incorporating the New-TransportRule cmdlet:

$Condition = Get-TransportRulePredicate SentTo
$Condition.Addresses = @(Get-MailContact ".First Address Book Entry")
$Action = Get-TransportRuleAction RejectMessage
$Action.RejectReason = "E-mail to the first entry in the GAL is not allowed."
$Action.EnhancedStatusCode = "5.7.10"
New-TransportRule -Name "Block e-mail to the first entry in the GAL" –Conditions @($Condition) -Actions @($Action) -Priority 0

New-TransportRule

With the new mail contact in the Global Address List, the new DSN created, and the transport rule set up, if you sent a test e-mail message to the new contact you will receive this NDR message back:

NDR message

Using this solution my objectives have been met: I didn’t have to create a mailbox or public folder, the email message doesn’t leave the Exchange environment, and the sender receives a useful error message.



This article has been viewed 8355 times.
Ben Lye

Author profile: Ben Lye

Ben Lye is a senior systems administrator at a multi-national software company. He has over 10 years experience supporting and administering Windows and Exchange, and has been MCSE and MCP certified since 1999. Ben is passionate about automating and streamlining routine tasks, and enjoys creating and using tools which make day-to-day administration easier.

Search for other articles by Ben Lye

Rate this article:   Avg rating: from a total of 7 votes.


Poor

OK

Good

Great

Must read
 
Have Your Say
Do you have an opinion on this article? Then add your comment below:
You must be logged in to post to this forum

Click here to log in.


Subject: Why First Entry in address book always get reply?
Posted by: xhftrueman@yahoo.com.cn (view profile)
Posted on: Wednesday, July 01, 2009 at 8:59 AM
Message: Hi Ben ,
My question is why First Entry in address always get reply ? because he is not in recipient's list ,why did the address was able to receive mail which he didn't regard.Thanks

Subject: Not replies but new messages
Posted by: benlye (view profile)
Posted on: Friday, July 03, 2009 at 9:47 AM
Message: @xhftrueman

The problem wasn't replies going to the first entry, it was new messages. The issue was with users inadvertently selecting the first address book entry when composing new messages, not replies.

Ben.

 





How to Kill a Company in One Step or Save it in Three
 The majority of companies that suffer a major data loss subsequently go out of business. Wesley David... Read more...

Migrating to Microsoft BPOS - Part II
 In his last article, Johan gave us a crystal clear guide to preparing to migrate from an on-premises... Read more...

Monitoring Mailbox Moves
 Mailboxes moves happen all the time, and given how precious the data in mailboxes can be, you should... Read more...

Emulating the Exchange 2003 RUS for Out-of-Band Mailbox Provisioning in Exchange 2007
 Exchange's Recipient Update Service was important in Exchange 2000 or 2003 in order to complete the... Read more...

The Postmasters
 The Exchange Team introduces themselves, and keeps you up-to-date Read more...

Upgrade Exchange 2003 to Exchange 2010
  In this article, the first of two in which Jaap describes how to move from Exchange Server 2003... Read more...

Upgrade Exchange 2003 to Exchange 2010 - Part II
 In Jaap's second article on upgrading straight from Exchange Server 2003 to 2010, he explains how to... Read more...

Goodbye Exchange ExMerge, Hello Export-Mailbox
 ExMerge was a great way of exporting a mailbox to an Exchange PST file, or for removing all occurences... Read more...

Using Exchange 2007 for Resource Booking
 The process of booking various resources to go with a meeting room just got a whole lot easier with... Read more...

Managing Exchange 2007 Mailbox Quotas with Windows PowerShell
 The use of PowerShell with Exchange Server 2007 can do a great deal to ease the task of managing... Read more...

Over 400,000 Microsoft professionals subscribe to the Simple-Talk technical journal. Join today, it's fast, simple, free and secure.

Join Simple Talk