Outlook - Update the existing Contact item

Asked By paresh
08-Feb-10 12:54 AM
Hi,

Could anyone please tell me how to update the Contact item? the following
code does not 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.
Outlook.MAPIFolder
(1)
Outlook
(1)
Application.GetNamespace
(1)
Outlook.ContactItem
(1)
DefaultContactsFolder.Items
(1)
OcontactItem.FullName
(1)
GetDefaultFolder
(1)
DefaultContactsFolder
(1)
  paresh replied to paresh
08-Feb-10 02:21 AM
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.
Create New Account
help
Handling application.quit event Outlook Hello, i am developing an exe application and i use global object to declare outlook application withevents. I use outlook 2007 sp2 and i am having trouble releasing my variable references or reusing then. I use this code : Public Class StartOE Private WithEvents o As Outlook.Application = Nothing Private ns As Outlook.NameSpace = Nothing Private omFolder As Outlook.MAPIFolder = Nothing Public Sub New() If detectOutlook() Then o = GetObject(, "Outlook.Application") Else o = New Outlook.Application End If Try ns = o.GetNamespace("MAPI") ' get namespace
Saving attachments to folder from public folder Outlook Hey there! I am currently working on a project that involves merging data from many into one Excel workbook for analysis. The csv files are sent to a public folder (outlook: \ Public Folders \ All Public Folders \ etc. . .) I thought the easiest way to do this would be to import the data straight from Outlook to the Excel file but after much painful testing I could not get it to main mailbox folders, not public and am unsure why. . . I have almost no experience with Outlook coding so any help is appreciated! This is the current code: If there is a instead of using a selection, that is fine too! Public Sub SaveAttachments() Dim objOL As Outlook.Application Dim objMsg As Outlook.MailItem 'Object Dim objAttachments As Outlook.Attachments Dim objSelection As Outlook.Selection Dim i As Long Dim lngCount As Long Dim strFile As String Dim strFolderpath
Create a macro in Outlook to run a rule Outlook I created a rule in Outlook 2007 for e-mails that have certain words in the subject line, to be deleted that and not have to click on tools, rules, etc. How do I do that? Outlook Program VBA Discussions Application.GetNameSpace (1) Outlook 2007 (1) Outlook (1) Outlook.NameSpace (1) VBA (1) VB (1) RunRuleDeleteSpam2 (1) RunRuleDeleteSpam (1) Sub RunRuleMyRule() Application
Iterating a Contacts folder for Outlook 2003 and 2007 in C# Outlook I need to iterate through all of the contacts in a contact folder. I have the contacts out of a Contact folder: Here is the first code I have tried: Outlook.Application Outlook = new Outlook.Application(); Outlook.MAPIFolder fldContacts = (Outlook.MAPIFolder)Outlook.Session.GetDefaultFolder(OlDefaultFolders.olFolderContacts); foreach (Outlook.ContactItem oItem1 in fldContacts.Items) { / / Get each
Proof Of Looping Bug in Reading Outlook Inbox From Access? Outlook Outlook Group: Here is a simple program run from Microsoft Access that loops through the Outlook Inbox and moves the mail from the Inbox to one of two folders: "Saved Mail comments would be appreciated. Option Compare Database Option Explicit Public Function IllustrateLoopBug() Dim OlApp As Outlook.Application Dim Inbox As Outlook.MAPIFolder Dim SavedMailFolder As Outlook.MAPIFolder Dim RejectMailFolder As Outlook.MAPIFolder Dim InboxItems As Outlook.Items Dim SavedMailItems As Outlook