Skip to content

Latest commit

 

History

History
81 lines (59 loc) · 2.55 KB

Outlook.Items.Add.md

File metadata and controls

81 lines (59 loc) · 2.55 KB
title keywords f1_keywords api_name ms.assetid ms.date ms.localizationpriority
Items.Add method (Outlook)
vbaol11.chm61
vbaol11.chm61
Outlook.Items.Add
0ee68068-1452-0f29-b85a-88b801ac0448
06/08/2017
medium

Items.Add method (Outlook)

Creates a new Outlook item in the Items collection for the folder.

Syntax

expression.Add _Type_

expression A variable that represents an Items object.

Parameters

Name Required/Optional Data type Description
Type Optional Variant The Outlook item type for the new item. Specifies a MessageClass to create custom forms. Can be one of the following OlItemType constants: olAppointmentItem, olContactItem, olJournalItem, olMailItem, olNoteItem, olPostItem, or olTaskItem, or any valid message class.

Return value

An Object value that represents the new Outlook item.

Remarks

If not specified, the Type property of the Outlook item defaults to the type of the folder or to MailItem if the parent folder is not typed.

Example

This VBA example gets the current Contacts folder and adds a new ContactItem object to it and sets some initial values in the fields based on another contact. To run this example without any error, replace 'Dan Wilson' with a valid contact name that exists in your Contacts folder.

Sub AddContact() 
 Dim myNamespace As Outlook.NameSpace 
 Dim myFolder As Outlook.Folder 
 Dim myItem As Outlook.ContactItem 
 Dim myOtherItem As Outlook.ContactItem 
 
 Set myNamespace = Application.GetNamespace("MAPI") 
 Set myFolder = myNamespace.GetDefaultFolder(olFolderContacts) 
 Set myOtherItem = myFolder.Items("Dan Wilson") 
 Set myItem = myFolder.Items.Add 
 myItem.CompanyName = myOtherItem.CompanyName 
 myItem.BusinessAddress = myOtherItem.BusinessAddress 
 myItem.BusinessTelephoneNumber = myOtherItem.BusinessTelephoneNumber 
 myItem.Display 
End Sub

This VBA example adds a custom form to the default Tasks folder.

Sub AddForm() 
 Dim myNamespace As outlook.NameSpace 
 Dim myItems As outlook.Items 
 Dim myFolder As outlook.Folder 
 Dim myItem As outlook.TaskItem 
 
 Set myNamespace = Application.GetNamespace("MAPI") 
 Set myFolder = _ 
 myNamespace.GetDefaultFolder(olFolderTasks) 
 Set myItems = myFolder.Items 
 Set myItem = myItems.Add("IPM.Task.myTask") 
End Sub

See also

Items Object

[!includeSupport and feedback]