Update the existing Contact item


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.
 
Ad

Advertisements

P

paresh

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top