Signatures With Date Fields In Microsoft Outlook
Ok, so today our CEO said he wanted everybody to stamp their emails with the sending date. It’s very simple to just add the date manually, but as you know, a good engineer is a lazy engineer. So this is how I did it:
Add “$$MYDATE$$” to your signature but without the quotes, then add this simple script to VBA:
1Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
2 If Item.Class = olMail Then
3 Dim Signature As String
4 Signature = Format(Now(), "d/m/yyyy")
5 Item.HTMLBody = Replace(Item.HTMLBody, "$$MYDATE$$", Signature, , 1)
6 End If
7End Sub
This should do it. This script will replace $$MYDATE$$ with the current date as soon as you hit the “Send” button. So you will still see “$$MYDATE$$” while you’re typing the message.
Just make sure you lower the macro security to medium.
Hope that helps
About Me
Dev gone Ops gone DevOps. Any views expressed on this blog are mine alone and do not necessarily reflect the views of my employer.
Recent Posts