Thursday, July 09, 2009

Exchange 2010 Hub Transport - building an automated signature


Update - 5/14/2012 - Per popular demand in the comments, I am highlighting up front that this method does not work as expected.  It attaches a signature at the bottom of every EMAIL, and not at the bottom of every new message.  So the bottom of a reply/all email will have everyone's signatures in a non-desirable manner.  I had hoped that in service packs MSFT might have updated this to deliver a more desirable result, but this has not yet occurred.  Thanks to my readers and commenters for asking me to update this!

This article is something I wish I could have done in 2007. You can now not only do disclaimers appended to an email, but you can customize the appended data using macros surrounded by two percent signs… for example %%displayName%% would display your Active Directory AD Display Name.
Do note that for these rules to fire, your outbound SMTP must be Exchange 2010. I haven't gotten that far into our migration yet, but created a new send connector to another domain to explicitly route out the 2010 server.
Reasons why you want to do this:
  1. Rich text sigs currently attach as images to each sent item and each reply. At 5-10k per message, that adds up a LOT under volume. With transport based signatures, these are applied on sending, and not saved in sent items. Since we use an IMG tag to support the image, it can go on an externally hosted web server.
  2. Corporate control of signature content based on Active Directory gives a LOT more centralized control. If we allowed marketing the ability to update this transport rule via the new Exchange control panel - they could add/update the marketing line in one place instead of asking employees to comply to a policy.
Below are the steps to create the Transport Rule (note that these all say edit - I didn't take initial screenshots, but the steps are identical)







So now, let's see what that looks like on the receiving end:



Ick. Not exactly pretty. And it missed the newline I entered. Let's see what we can do with this. Trying HTML:


This results in:


I obviously skipped the tough part here just to proof of concept the formatting.
Let's see if some insane winword formatted HTML makes this break - Best practice here would be to have your web development company trim this down a LOT. This text block is 5k!

This got me here - can you tell which is from Outlook and which is generated? ( I fixed the </ there after!)




To make the HTML more navigable, I got it down to about 1kb!

OK, so we now KNOW we can duplicate a rich text signature - let's see what I can make work from AD. This is far from a complete list, just what I found with some gentle poking. I expect that Microsoft will eventually list a complete mapping of Macros to fields. If that doesn't happen for a long time, I will update this post or make a new one to list more.
Display Name%%displayName%%
First Name%%FirstName%%
Last Name%%LastName%%
Business Phone%%Phone%%
Title%%Title%%
Fax%%Fax%%
Manager%%Manager%%

Unfortunately, I have not yet been able to find a slick way to pull Manager's email address out of this to REALLY complete the same effect.



That transport sig cost zero kb in the sent items, but if someone replies will add the 1k of html to the replied to email. Still a decent reduction if you multiply over many users and many emails.
Not too shabby, right? Now - other things like the certifications or the second phone number can be applied by either different transport rules based on departments, or by inserting additional desired fields into other attributes. If a marketing department wants to cross sell services more, they can put the top ten technologies on one transport rule, and the Exchange 2010 seminars on another transport rule, and modify the rules to apply by distribution group membership.

20 comments:

Anonymous said...

Cool, thnx for the info.

Just tried it and it works realy well.

Iceknight said...

These codes should mostly work: http://technet.microsoft.com/en-ca/library/bb738157(EXCHG.80).aspx

Thugn said...

This works wonderfully for most instances. The exception I have found is with Blackberry devices. The blackberry renders all emails in plaintext. Emails created via blackberry will show all the HTML tags (i.e. body html b ) Has anyone found a fix for this?

Cheers!

Franziska und Patrick said...

thx for the info!!
i have the same exeption by sending a mail with an iPhone. html tags are visible and breaks doesn't work. any ideas?

Travi said...

Awesome, thanks for the help!

Lance said...

Great, but how does one add the signature to the end of the body and not the entire email? Is there a switch for removing the "append" option?

Cheryl said...

The problem with this is that signature appears at the very bottom of the email, so if there is conversation it keeps going to the bottom...any thoughts?

Chris said...

Cheryl - Yes, this is the MAJOR lacking of this. It really looks awful after the second or third reply in a row. I never bothered updating the post regarding this, sorry about that. There are third party tools for standardizing sigs at the server and desktop levels.

Rich said...

cheryl,
what i did to fix this was add

or except when the Subject field or message body contains 'this message is strictly prohibited'

which in the bottom of our disclaimer
Confidentiality Notice: This e-mail message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient and received this in error, please contact the sender by reply e-mail. You are hereby notified that the copying, use or distribution of any information or materials transmitted in or with this message is strictly prohibited.

jchongers71 said...

I have a small problem with this. How do you handle forwards and replies? When this rule is active if a user replies to a message or forwards a message, you will have a long list of signatures at the bottom of the email, instead of each signature after the body of the message.

Scott Mckenzie said...

With regard to forwards and replies, i have set an Exception that goes as follows:

"except when the Subject field contains specific words"

and then added:

Re: and Fw:

This seems to work for the most part.. it's not perfect but hey!

SexyTan said...

Could you please amend this to say at the very top that in order for this to work like a signature and place the transport rule on the bottom on each new email and not the enitre email that they have to purchase third party software? Please. I spent a week setting this up only to find that I could not use it :( :( :(

Corbett Enders said...

As Rich has already said, you can enforce only a single signature per thread by:

create an exception on the transport rule for "when the Subject field or message body contains" and include a portion of the signature text (such as their title or phone number, etc).

Rutger de Boer said...

What you can do to fix the problem of disclaiming every email:

$text="(html)(Body)(div)(p)(font size='2' face='Arial')YOUR HTML CODE GOES HERE(/font)(/p)(/div)(/body)(/html)"
$domainList="internaldomain1","internaldomain2","internaldomain3"
New-TransportRule -Name "Your Rule Name" -SentToScope NotInOrganization -SenderADAttributeContainsWords "customattribute2:VALUE" -ApplyHtmlDisclaimerText $text -ExceptIfRecipientAddressContainsWords $domainList -ExceptIfHeaderContainsMessageHeader "X-DisclaimerAdded" -ExceptIfHeaderContainsWords {Default} -ApplyHtmlDisclaimerLocation Append -ApplyHtmlDisclaimerFallbackAction Wrap -SetHeaderName "X-DisclaimerAdded" -SetHeaderValue "Default"

This will put a value: X-DisclaimerAdded to every mail and at the same time let's the rule fire only on messages that have no such value in the header.

All <> HTML tags have been replaced.

Doodlebug Dinglehoppe said...

An alternative to having only one signature is to prepend it instead of append. Then the signature shows up properly at the top of each reply.

Doodlebug Dinglehoppe said...

An alternative to having only one signature is to prepend the text instead of appending it. Then the correct behavior is exhibited.

gopher said...

I create an except and when I answer I dont attache a signature, but I wont atache something like second signature or small info which containe only "best regsard and my phone number" how do i do this ?

arjay said...

Hi Everyone,
Is there an update or a summary of solutions to this problem as of 3/5/2013.

Does Issue still exists and what have you found to be the best solution you now have in production? ie has anyone revised how they are doing this now?

my main issue is that i need to pull info in for for MAC Clients from AD to toe the corporate brand line...which is something none of the signature manager programs do..as alot of them push a client msi to windows computers and therefor do not support outlook for mac 2011.

Many thanks to all who posted, i will look into testing them out

Sheldon Marquez said...

Prepend does not exhibit "normal" behavior if you are attempting signature blocks. The signature block should appear directly AFTER your text, where as prepending will generate the signature block BEFORE your text.

Randescy said...

How do I run an "if" check on these commands? IE some users want to list there home phone number and I don't want that to show as a blank line if it isn't in AD. With vbscripting was easy to figure out. This exchange built in Macro thing not so much.

Basically I want to do this:
if %%homePhone%% then %%homePhone%%