Powershell – Exchange deferred delivery: update message “Date:” header

exchange-2007powershell

A client is using the "deferred delivery" feature in Outlook / Exchange. For some reason this feature does preserve the original message creation time (i.e. when the user has hit the "send" button) as the RFC-822 Date: header, so even when the message's delivery is indeed "deferred", the headers still bear the evidence that it has been composed a while before delivery. My client would like to set the Date: header to the time when the message actually leaves the Exchange organization instead, so it would look like it had been composed and sent recently.

The idea to solve this is to set the Date: headers on all outgoing SMTP mail to the server's current time in an Exchange 2007 environment.

I know that I can set up a new-Transportrule with the -Action parameter set to Microsoft.Exchange.MessagingPolicies.Rules.Tasks.SetHeaderAction and define to replace "Date" with a different value. However, I cannot see a way to use a dynamic return value of function like Get-Date in there – at best the result of Get-Date gets converted to a static value it had when executing the new-Transportrule cmdlet.

A lambda expression / closure would perform the required function (i.e. not insert a static value but a function pointer and re-evaluate the expression on each run), but as I understand, Powershell does not support those.

An ugly workaround would be a very frequent redefinition (like once every minute) of the transport rule with the updated current time, but I would like to avoid this if a more elegant solution is available.

Any ideas on this?


Edit
To give a short explanation on why the feature is used: the client wants to send mail containing a decision result which must not be public before a certain date. Addidionally, he also wants to conceal the date / time when the decision was met to prevent needless discussions.

This is actually a feature of the MUA (Outlook supports this out-of-the box), but server support is of course an added benefit as the mail would be sent even when the client is not running. There also is the problem: the MUA sets the "Date:" header upon message transmission to the server and the server does not change it upon release off the wait queue. There used to be two features in Outlook which performed a similar function – one was called "Deferred delivery", one was called "Deferred Submission". Obviously, the latter is what is neeed here, but it has been removed in Outlook 2000 and was never re-introduced – possibly because the Outlook team was trying to learn from Apple.

Best Answer

Set the Outlook client to not Send immediately when connected. They compose the message and hit Send as they normally would. The message sits in their Outbox. When they "actually" want to send the message, just open it up from their Outbox and click Send again, it will re-timestamp the message. Then do a Send/Receive in Outlook. No evidence of the original composition date/time can be seen in the header. Alternatively (and probably a better solution), just compose and save the message in Drafts and then Send it when you actually want to send it...

I am aware that this is not a solution like you are describing you want at the server level globally for all messages, but more of a workaround for the client. It becomes very annoying if there are a lot of these messages to do this on, but a couple a week/month won't be too bad for them. Weird requirement from the client..."Send the message, but DON'T ACTUALLY send the message until I say so..." If you don't want to send the message, DON'T hit the Send button...

Another possibility is to not even use Outlook to send the message, compose the message in notepad, saving it as an eml file in the supported format, and write a script to drop it in the Pickup folder on the Exchange server at the appropriate date/time to be delivered.