CreateItemFromTemplate Method

Microsoft Outlook Visual Basic

Show All

CreateItemFromTemplate Method

       

Creates a new Microsoft Outlook item from an Outlook template (.oft) and returns the new item.

expression.CreateItemFromTemplate(TemplatePath, InFolder)

expression   Required. An expression that returns an Application object.

TemplatePath   Required String. The path and file name of the Outlook template for the new item.

InFolder   Optional Variant. The folder in which the item is to be created. If this argument is omitted, the default folder for the item type will be used.

Example

This Visual Basic for Applications example uses CreateItemFromTemplate to create a new item from an Outlook template and then displays it.

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItemFromTemplate _     ("C:\Program Files\Microsoft Office\Templates\Outlook\While You Were Out.oft")
myItem.Display

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

Set myItem = Application.CreateItemFromTemplate _     ("C:\Program Files\Microsoft Office\Templates\Outlook\While You Were Out.oft")
myItem.Display