Categorie
Information and Communications Technology

VBA Macro Example to Update Outlook Contacts

This is a simple macro example that describes how to update outlook contacts:

Sub updateContacts()
    Dim ContactsFolder As Folder
    Dim Contact As ContactItem
    Set ContactsFolder = Session.GetDefaultFolder(olFolderContacts)
    i = 0
    For Each Contact In ContactsFolder.Items
        first_name = Contact.FirstName
        middle_name = Contact.MiddleName
        last_name = Contact.LastName
        If middle_name <> "" Then
            Contact.FirstName = first_name & " " & middle_name
            Contact.MiddleName = ""
            Contact.Save
            i = i + 1
        End If
    Next
    MsgBox ("Contacts Found: " & ContactsFolder.Items.Count & ", Updated: " & i)
End Sub

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *