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
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.