Reputation: 446
I am developing a desktop application using C#, and I do not know how to edit a contact info in outlook, I Google-d it but no use.
I know how to retrieve and add contacts to outlook, what I am asking about is updating contacts.
any suggestions?
Upvotes: 2
Views: 4015
Reputation: 2857
http://geekswithblogs.net/timh/archive/2006/05/26/79720.aspx
I might try to above. It looks like first you reference the Outlook COM object, and then create a Microsoft.Office.Interop.Outlook.Application
from which you should be able to edit outlook objects.
Upvotes: 0
Reputation: 446
The solution is quite easy, though I did not find it using google.
retrieve the outlook contact.
Outlook.Items ctcItems = cf.Items;
Outlook.Items items = ctcItems;
Outlook.ContactItem ctc = (Outlook.ContactItem)items[index];
cf in the code above is the Outlook.MAPIFolder
.
update the Outlook.ContactItem
.
ctc.FullName = "Laurel";
. . . . .
save Outlook.ContactItem
.
ctc.Save();
Upvotes: 3
Reputation: 21
Another solution.
Microsoft.Office.Interop.Outlook.Application outlookApp = new
Microsoft.Office.Interop.Outlook.Application();
MAPIFolder Folder_Contacts = (MAPIFolder)
outlookApp.Session.GetDefaultFolder(OlDefaultFolders.olFolderContacts);
var filter = String.Format("[FullName] = '{0}'", "Jose da Silva" );
ContactItem contact = (ContactItem)Folder_Contacts.Items.Find(filter);
if (contact != null)
{
contact.FullName = "Joao da Silva";
contact.Email1Address = "[email protected]";
contact.Save();
}
Upvotes: 1
Reputation: 13601
Download and install VSTO, then add a reference to Microsoft.Office.Interop.Outlook
to your project. This will give you access to the Outlook object model.
Upvotes: 1