DSN messages exist to notify either the Exchange user or the Administrator of errors or delays that Exchange has had when delivering messages. There are three types of messages:
Success (which are indicated by a code of 2.x.x in the DSN)
Persistent Transient Failure (which are indicated by a code of 4.x.x in the DSN and occur when the email server encounters an error which may only be temporary)
Permanent Failure (which are indicated by a code of 5.x.x in the DSN and occur when the server encounters an error which it cannot get round)
The other type of messages which is now customizable are messages related to mailbox quotas such as those telling you that you are nearing your limit or those telling others that you have reached your mailbox size limit. Exchange also sends three types of Quota messages:
Mailbox or public folder exceeds its Issue warning limit (the lowest storage quota).
Mailbox exceeds its Prohibit send limit or a public folder exceeds its Prohibit post limit (the middle storage quota).
Mailbox exceeds its Prohibit send and receive quota (the highest storage quota).
For as long as I have been a user on, or an administrator of Exchange systems, this topic is something which has been discussed. The built-in DSN or System messages were never very user friendly and often led to more confusion and therefore support calls were then necessary. With Exchange 2003 and earlier the only way around some of these problems was by using third party tools. Now, with Exchange 2007, Microsoft have finally built these features into Exchange, although as with quite a lot in the Release to Manufacturing (RTM) version, the configuration method is command line only. Thankfully, there is another way for the more GUI oriented which I will show at the end of the article.
Before we start customizing, it should be noted that to perform these procedures you must have Exchange Organization Administrator permissions. On top of that, customised messages can only be sent to those with the locales listed in Table 1.
Table 1: The locales available to be specified in System Message Commands
There is great flexibility provided for the customization of DSN messages. You can create different DSN messages to be sent to people from different locales. You can also differentiate between internal and external users. All of these choices can be applied to specific DSN messages by the code they contain for example “5.4.0” for recipient server not found in DNS.
Before we start creating DSN messages it is very important to know what they are allowed to contain. DSN messages can contain 512 characters. They can also contain HTML. In fact, by default Exchange 2007 sends HTML DSN messages although this can be changed both for internal and external recipients independently using the InternalDsnSendHtml and ExternalDsnSendHtml parameters. The HTML tags allowed are listed in Table 2.
Table 2: The HTML tags allowed in DSN messages
Finally, certain characters have special meanings (for example being used to surround HTML tags). Therefore the escape codes shown in Table 3 should be used in their place.
Table 3: Escape codes used to replace “special” characters
Having discussed the composition of DSN messages we can finally get on to working with them
First, here is how to view the existing configuration.
Get-SystemMessage –Original >c:\DSNOriginal.txt
The first command above should not return any output as it only lists custom messages of which we have not yet created any. The second command will output all the existing default messages. Because the output is very long, I have piped it to a text file for easy viewing.
Having viewed the list of existing messages let us now create a new one to make it a little more user friendly. We will replace the message you receive when you send a mail to an incorrect address so that it will now point people to the helpdesk.
The original DSN message is shown in Figure 1.
Figure 1: DSN message received after sending a mail to the incorrect email address
At the bottom of the mail you can see the error code “5.1.1”. This tells us which DSN message we need to replace. To create a new DSN message use the following command:
New-SystemMessage -DsnCode 5.1.1 -Internal:$True -Language en -Text "Enter Text Here"
You can see that you must specify the code you require, whether the message is for Internal or External consumption and also the locale of the message.
Now to set the text to what we really want, we will edit the message we just created using the command below:
Set-SystemMessage -Identity en\internal\5.1.1 -Text "<BR> You have entered an email address which doesn't exist on the system. <P>Please check the address book or, if you think the address is correct contact the helpdesk using the<B>following</B> link.</P> <A HREF='intranet.company.local'>IT Helpdesk</A> <BR>"
You will see in the command above that I have used various HTML elements to create a nice layout as shown in Figure 2.
One thing which is important is that you use the right type of quote marks ‘ or “. You must use “ to surround the entire text entry but ‘ to surround any URLs entered.
Figure 2: The newly created DSN message with HTML links and formatting
The last simple operation that can be performed to custom DSN messages is to remove them. This is done using the following command:
Remove-SystemMessage -Identity en\internal\5.1.1
Having covered all the general operations that can be performed with custom DSN messages, I will now touch on another area in which they can be used. Exchange 2007 introduced the concept of transport rules which are configured on Hub or Edge Transport servers to carry out actions when a certain type of mail is received. One use of these rules is to prevent certain users of the system communicating with other users of the system, a scenario now called an “Ethical Wall”. Using the commands above you can now create your own DSN messages/codes to enable you to create specific messages for the different transport rules you create. For more information about setting up this type of message see the link below:
Customizing Quota Messages
Having shown you how to use the SystemMessage commands in the previous section, you are now well placed to make your own Quota messages. That is because the same commands are used, albeit with an additional switch; the QuotaMessageType parameter. The following command shows how the QuotaMessageType parameter is used and will create a new custom quota message which will be received when your mailbox is too full to allow you to send mail:
New-SystemMessage -QuotaMessageType ProhibitSendMailbox -Language EN -Text "You can’t send any more mail. Your mailbox is too full!"
As you can see the command is very similar to setting up a new custom DSN except the DsnCode parameter is replaced with the QuotaMessageType parameter.
The following values are acceptable for use with the QuotaMessageType parameter:
For details of exactly what the messages refer to see the link below:
Finally, the only other difference between custom DSN commands and custom quota message commands is in the use of the Identity parameter. Instead of the DSN code, the Quota messages are identified by locale and name for example:
Having worked through the examples above I hope you now have a good idea about how custom DSN and quota messages work in Exchange 2007. One thing you will clearly have noticed is that all these commands are carried out in the Exchange Management Shell. If you are looking for a GUI method to change some of these settings, take a look at PowerGUI (discussed in more depth here) which may be able of help. All that is needed now is for you to take a look at where they can best be used in your Exchange environment.