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?
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();
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.
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 = "joao@silva.com.br";
contact.Save();
}
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.
精彩评论