Outlook Developer Home
Outlook Programmer's Library
Outlook Technologies
Outlook Forms
Other Technologies



Main Heading

The large text box on an Outlook item -- called Message or Notes in the Field Chooser -- actually represents the Body property. This code sample adds the current date/time and the user's name by appending it to the existing Body. We offer versions that work with an Outlook toolbar button or a command button on a form. 

VBA Code Sample  | Command Button on a Form | Notes | More Information

VBA Code Sample

This code is aimed at Contact items. You can adapt it for other types of items as well. Put the code below in an Outlook VBA module and associate it with a toolbar button.

 Back to Top

Command Button on a Form

With the form in design mode, add a command button from the control toolbox and, in its Properties dialog, name it cmdStampDate. Then add this code to the form:

 Back to Top

Redemption SafeInspector

This version, which can be called from VBA or VBScript as InsertDateTimeStamp True or InsertDateTime False, uses the SafeCurrentUser and SafeInspector objects from Redemption to avoid security prompts and offer a choice of inserting at the top or bottom of the item. Text inserted at the top inherits the format of the first line of text. Text inserted at the bottom inherits the format of the last line of text.

 Back to Top


Setting the Body property in any Outlook item removes any existing formatting in the item. Also, for an Outlook 2000 message item, it changes the format to rich-text.

Reading Item.Body will trigger a security prompt in Outlook 2002 SP3.

Using Namespace.CurrentUser will trigger a security prompt in Outlook 2000 and 2002. See Listings 10.10, 12.8, and 20.7 in the sample code for my book for alternatives that don't trigger a prompt.

To expand the VBA version to other types of items besides contacts, use a Select Case or If ... End If block to check the Class property so that you know what type of item you're working with.

[FrontPage Scheduled Image Component]Unless you are working with a MailItem or PostItem and using Word as the email editor, Outlook provides no known way to control the cursor position in an Outlook item, which means you can't insert the date, then put your cursor in a particular place. This functionality is available in the SafeInspector object supported by the third-party Redemption library. Back to Top

More Information

2002-7 TurtleFlock, LLC
All right reserved.
About OutlookCode.com

Send comments to webmaster@outlookcode.com

Designed and Implemented by TerraLink USA 

FrontPage Integration
by RobsonDesignWorks

get Sue's code | forums | share your own code | registration