0 out of 1 rated this helpful - Rate this topic

CreateItem Method

Office XP
 

Creates a new Microsoft Outlook item and returns it. The CreateItem method can only create default Outlook items. To create new items using a custom form, use the Add method on the Items collection.

expression.CreateItem(ItemType)

expression   Required. An expression that returns an Application object.

Example

This Visual Basic for Applications example uses the CreateItem method to create a new contact in the default Contacts folder and then displays the new item.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(olFolderContacts)
Set myItem = myOlApp.CreateItem(olContactItem)
myItem.Display

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myNameSpace = Application.GetNameSpace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(10)
Set myItem = Application.CreateItem(2)
myItem.Display
Did you find this helpful?
(1500 characters remaining)