Update the existing Contact item

  • Thread starter Thread starter paresh
  • Start date Start date
P

paresh

Hi,

Could anyone please tell me how to update the Contact item? the following
code doesn't work. I want to update the fullname of existing contact item.
(all messageboxes prints the same existing fullname even after changing and
saving it)

Dim defaultContactsFolder As Outlook.MAPIFolder
Dim ocontactItem As Outlook.ContactItem
Dim ocontactItems, i
Set defaultContactsFolder =
Application.GetNamespace("MAPI").GetDefaultFolder(olFolderContacts)
Set ocontactItems = defaultContactsFolder.Items
MsgBox ocontactItems(1).FullName
ocontactItems(1).FullName = "testing"
MsgBox ocontactItems(1).FullName
ocontactItems(1).Save
MsgBox ocontactItems(1).FullName

Thanks.
 
Got it working. I need to set ContactItem object.

Dim defaultContactsFolder As Outlook.MAPIFolder
Dim ocontactItem As Outlook.ContactItem

Dim ocontactItems, i
Set defaultContactsFolder =
Application.GetNamespace("MAPI").GetDefaultFolder(olFolderContacts)
Set ocontactItems = defaultContactsFolder.Items
Set ocontactItem = ocontactItems(1)
MsgBox ocontactItem.FullName
ocontactItem.FullName = "testing"
MsgBox ocontactItem.FullName
ocontactItem.Save
MsgBox ocontactItems(1).FullName

Thanks.
 
Back
Top