New contacts can be created in a manner similar to composing new emails. The following example demonstrates this process:
Sub CreateContact()
Dim appOutlook As Outlook.Application
Dim contactItem As Outlook.ContactItem
' Start Outlook application
Set appOutlook = CreateObject("Outlook.Application")
' Create a new contact item
Set contactItem = appOutlook.CreateItem(olContactItem)
' Assign properties to the contact
contactItem.LastName = "Muster"
contactItem.FirstName = "Max"
contactItem.Email1Address = "max.muster@mailziel.de"
' Save the new contact
contactItem.Save
' Quit Outlook and clean up
appOutlook.Quit
Set contactItem = Nothing
Set appOutlook = Nothing
End Sub
Explanation:
The CreateItem() method of the Outlook application object is used here with the constant olContactItem to create a new item of type ContactItem. This generates a blank contact form.
Next, the script assigns values to key properties of the contact, specifically the last name (LastName), first name (FirstName), and primary email address (Email1Address).
Finally, the new contact is saved to Outlook’s contacts folder using the Save() method.
The Outlook interface will then display this newly created contact, as illustrated in the referenced figure.