Outlook VBA Script that creates a new Contact

Option Explicit

' VBA Script that creates a new contact and displays it
' Use Tools->Macro->Security to allow Macros to run, then restart Outlook
' Run Outlook, Press Alt+F11 to open VBA
' Programming by Greg Thatcher, http://www.GregThatcher.com

Public Sub CreateNewContact()
    On Error GoTo On_Error
    Dim contactItem  As Outlook.contactItem
    
    Set contactItem = Application.CreateItem(olContactItem)
    
    contactItem.FullName = "Greg Thatcher"
    contactItem.Email1Address = "gregt@xobni.com"
    contactItem.BusinessTelephoneNumber = "415 555 1212"
    contactItem.HomeTelephoneNumber = "415 555 1234"
    contactItem.MobileTelephoneNumber = "415 555 1236"
    ' contactItem.AddPicture ("C:\Users\Public\Pictures\Sample Pictures\jellyfish.jpg")
    contactItem.Display
    
Exiting:
        Exit Sub
On_Error:
    MsgBox "error=" & Err.Number & " " & Err.Description
    Resume Exiting

End Sub


Problems, Comments, Suggestions? Click here to contact Greg Thatcher
Please read my Disclaimer





Copyright (c) 2013 Thatcher Development Software, LLC. All rights reserved. No claim to original U.S. Gov't works.