How to Insert the Date and Time into an Outlook Item

Last reviewed on July 28, 2012

One often requested feature that is missing in older versions of Outlook is ability to insert a date and time stamp into the body of Outlook items. While Outlook doesn't offer it directly, you can use a custom form or an add-in to insert the date stamp.

While this is not needed in Outlook 2007 and Outlook 2010 as both include the Insert Date and Time command found in Word, you can use it if you prefer.

One complaint about Outlook 2007, 2010 or 2013’s Insert Date & Time command is that it is too many steps. It’s not bad if you use the keyboard shortcuts: Alt+N, D, Enter will insert the date and time format you have set as default. To insert other formats, use the arrow keys to select them, then press Enter. (Home or Page Up jumps to the top entry on the list while End or Page Down jumps to the bottom.)

See the Tools section below for add-ins that you can use instead. Note that the custom forms method doesn't work well with Appointment forms since you can't change the first page of the form. It also doesn't work well with contacts in Outlook 2003 and 2007 since editing the first page of the form reverts the form to the older Outlook contact form (as in the screenshot below).

Custom Form Method with Button

In a new Outlook 2003 or older, open a form then:

  1. Select the Tools menu, Forms, Design this form
  2. Then from the View menu, choose View code
  3. In the code window, enter this code:

In Outlook 2007 and up, first show the Developer ribbon (File or Office icon, Options), then from the Developer ribbon, choose Design this form. The View Code button is in the Form section.

Sub StampDate()
   Item.Body = Now() & vbCrLf & vbCrLf & Item.Body
End Sub


Sub CommandButton1_Click() 
  Call StampDate() 
End Sub

Add a date stamp to a custom form After entering the code, close the code window.

Next:

  1. Open the Control toolbox and drag a command button to the form.
  2. Rename it by right clicking on it and selecting Properties.
  3. In the Caption field, type in the desired name.

To use, click the button you created.

Custom Form – Automatic Method

If you want the date stamped in the Notes field every time you open an item, you can create a custom form as described above, but use the code below instead. You also won’t need to add a button to the form, so it will work with contacts. Although today’s date is added to the Notes field every time you open a contact, it’s not saved until you Save the contact.

In Outlook 2007 and up, first show the Developer ribbon (File or Office icon, Options), then from the Developer ribbon, choose Design this form. The View Code button is in the Form section.

In Outlook 2003 and older, or Outlook 2007’s main window, go to Tools menu, Forms, Design this form. Then from the View menu, choose View code.

In the code window, enter this code:

Function Item_Open()
Item.Body = Now() & vbCrLf & vbCrLf & Item.Body
End function

Publish the form and set it as the default form for the folder, if desired. If you want to use it with existing items you’ll need to convert the items to use the new form. Instructions are at How to Set a Custom Form as the Default for a Folder.

Tools

DocMessageClass

Used to change the message class of Outlook items,so that existing items will use newly created forms.Free.

Insert Date-Time

Stamp any Outlook item with your name and the date/time, in various formats and locations. Enter code WD9BHK53 during checkout.

More Information

To stamp a date on a Microsoft Outlook item (Outlookcode)

Written by

Diane Poremsky
A Microsoft Outlook Most Valuable Professional (MVP) since 1999, Diane is the author of several books, including Outlook 2013 Absolute Beginners Book. She also created video training CDs and online training classes for Microsoft Outlook. You can find her helping people online in Outlook Forums as well as in the Microsoft Answers and TechNet forums.

Please post long or more complicated questions at Outlookforums.

27 responses to “How to Insert the Date and Time into an Outlook Item”

  1. Jessica Jablonski

    Diane -
    Can you tell me why when you try to edit the first page of the contact form that it reverts back to 2003 layout? It is so frustrating... is there any way to fix/update this?

  2. Charlie Cato

    Diane -

    I've tried the steps outlined above to add a custom button to an Outlook 2010 Contact form to automatically add the Date/Time when clicked..

    When I first entered the code exactly as shown and ran the form in Developer Mode, I got a Script Error telling me that a "Sub" was expected in Line 7 of the Script, i.e. the line in your sample code above which is coded as "End".

    So I added a "Sub" command to that line. The code as now showing in the Code Viewer is:

    Sub StampDate()
    Item.Body = Now() & vbCrLf & vbCrLf & Item.Body
    End Sub

    Sub CommandButton1_Click()
    Call StampDate()
    End Sub
    End Sub

    The form now runs OK in Developer mode and the button shows up as expected on the Contact form. The problem is, when you click it, it does nothing. So I concludethat something is amiss in the "StampDate" sub-routine, but I don't know enough about Visual Basic to figure it out. (My glory days as a coder were 20+ years ago in the days of dBase II!)

    Can you give me any guidance. Thank you.

  3. Charlie Cato

    Thanks. That seemed to do the trick.

  4. Lino Wchima

    Hi Diane,

    I adapted an earlier code published by you, in order to insert the today date in a message body by clicking a button in my ribbon:

    Sub InsertarFechaDeHoy()

    ' Por una única vez en Visual Basic de Outlook (Alt+F11):
    ' Add reference to Word library in VBA Editor, Tools, References

    Dim objItem As Object
    Dim objInsp As Outlook.Inspector

    Dim objWord As Word.Application
    Dim objDocu As Word.Document
    Dim objSele As Word.Selection

    On Error Resume Next

    'Reference the current Outlook item
    Set objItem = Application.ActiveInspector.CurrentItem

    If Not objItem Is Nothing Then
    If objItem.Class = olMail Then
    Set objInsp = objItem.GetInspector
    If objInsp.EditorType = olEditorWord Then
    Set objDocu = objInsp.WordEditor
    Set objWord = objDocu.Application
    Set objSele = objWord.Selection

    objSele.InsertDateTime DateTimeFormat:="yyyy-MM-dd", InsertAsField:= _
    False, DateLanguage:=wdSpanishColombia, CalendarType:=wdCalendarWestern, _
    InsertAsFullWidth:=False

    End If
    End If
    End If

    Set objItem = Nothing
    Set objWord = Nothing
    Set objSele = Nothing
    Set objInsp = Nothing

    End Sub

    It works great, thank you.

    Could it be easier using only SendKeys?

  5. Alex Z

    Hello DIane!!!
    Im really liking what you did here and was wondering if that could be implemented into what im trying to do.
    Body of my email message
    Date and Time: System Generated.(The computer's time should be time-stamped in this email.)
    Event Type: {Outage, Degradation,Information,...}
    Location: {Germantown, North Las Vegas, Detroit,...}
    Event Status: {Investigation,Outage,Information}

    An example of how I'm trying to set this email message up as

    Subject: (Status of the problem I'm sending)

    Date and Time: 02/01/2013
    Event Type: Outage
    Location: Germantown
    Event Status: Investigation

    Please if you could help me out I would be so grateful. I'm new to programming and have been looking around for weeks and nothing that could point me in the direction that I should be going for this. It would make my reports much easier if I could get this going. Its such a tedious thing for filling this out every day. I've been playing around with this but its becoming frustrating =(

  6. johnmerd

    Diane,

    Thanks for your insert date code. I have modified it and it works great. How can I bold the first line and leave the remaining lines alone?

    Function Item_Open()
    Item.Body = Date() & " - " & Application.GetNamespace("MAPI").CurrentUser & " Notes:" & vbCrLf & vbCrLf & vbCrLf & "------------------------------------------" & vbCrLf & Item.Body
    End function

    I have spent several hours trying to do this. I would REALLY appreciate your help. Thanks. John,

  7. johnmerd

    Diane,

    Thanks for your message. Seems like it would be a simple thing. I'm figuring if you don't know how to do it, maybe it can't be done. If you discover something that would work I would really appreciate an update. Thanks much.

  8. johnmerd

    Thanks for the effort Diane. I am giving up on bolding for now. One more question. The code you provided enters the time/date stamp on the first line of the notes and pushes everything that was already in the notes down. Is it possible to leave a line or two at the top of the notes area alone so it doesn't get pushed down with everything else? I was hoping to use the first line for some company info that we would like fixed at the top of the notes area. Hope this one is easy!!!!! Thanks.

  9. johnmerd

    Diane,

    Thanks much. This is what gave me the 2 lines. Added a vbCrlf in line 3. Works great.

    Function Item_Open()
    arr = Split(Item.Body,vbCrLf,2)
    Item.Body = arr(0) & vbCrLf & vbCrLf & Date() & " - " & Application.GetNamespace("MAPI").CurrentUser & " Notes:" & vbCrLf & vbCrLf & vbCrLf & "------------------------------------------" & vbCrLf & arr(1)
    End function

  10. johnmerd

    Diane,

    This works, but the formatting of the first 2 lines is removed when it runs? Why is that? Is there a way to maintain the formatting? Almost there .....

    John

  11. johnmerd

    Thanks much. I'll have to dig into this.

    Question: When I open the calendar appointment, the date and lines are automatically inserted above the old notes as it's supposed to do according to the code we derived. However, when I just want to view the notes, Outlook thinks I made changes because of the date and lines inserted, and when I close I have to click on the x in the corner, and then answer the pesky "Do you want to save changes?" Pop up. Is there anyway to turn this off, or create a macro to close and then answer "no"? Any suggestions?

    Thanks,
    John

  12. johnmerd

    Diane,

    Thanks for all your help. We view appointment details a lot without making changes, and so we are going to get around the issue by using a macro button on the Appointment Ribbon. I know how to create a macro and put it on the Ribbon. Here is the question:

    The same VBA code that I have used successfully in the custom form method with button (pasted into view code) does not work when creating the macro. How would I make the following code work as a macro?

    Sub StampDate()
    Item.Body = Date() & " - " & "JM Notes:" & vbCrLf & vbCrLf & vbCrLf & "ACTION: " & vbCrLf & "----------------------------------------------------------------" & vbCrLf & Item.Body
    End Sub

    I keep getting an error regarding the second line. Please help!

  13. Obi Ejiofor

    Dear Diane i need to configure adding a timestap automatically to an autoreply mail for a shared mailbox. We user outlook 2010 and exchange 2010 how would i script this in VBA ?

  14. Obi Ejiofor

    We are using an autoreply rule. The user wants an time stamp added to each autoreply mail sent from the shared mailbox.

Leave a Reply

If the Post Coment button disappears, press your Tab key.