Visual Studio Developer Center >
Visual Studio Forums
>
Visual Studio Tools for Office
>
Import Outlook contacts
Import Outlook contacts
- I have imported Outlook Contacts but i have two issues in that,
a) I have imported outlook contacts by using GetDefaultFolder() using AddressList.So, i can import all the contacts email id in the AddressBook(ShowNames from the) but iam not able to load FirstName and LastName of the Contact.
b) I have imported outlook contacts by using GetDefaultFolder() using ContactItems.So,i can import contacts(emailid,firstname & lastname) only in few folders.Not able to access contacts from all folders.
Can anyone guide me how to access all contacts from all folders with their FirstName and LastName?- Changed TypeBessie ZhaoMSFT, ModeratorTuesday, November 10, 2009 8:48 AM
All Replies
- Hello Aki,
For issue a, it seems that you are creating a contact item for a address entry object. You could use the GetContact method [See: AddressEntry.GetContact Method]. I have made a test in my side, and I can see the first name and last name. For test, I set the index to 1. Code like this,
Outlook.AddressList addlist = this.Application.Session.AddressLists[1];
Outlook.AddressEntry addentry = addlist.AddressEntries[1];
Outlook.ContactItem ci1 = addentry.GetContact();
ci1.Display(missing);
<<I have imported outlook contacts by using GetDefaultFolder() using ContactItems.So,i can import contacts(emailid,firstname & lastname) only in few folders.Not able to access contacts from all folders.>>
For issue b, I am little confused about . Could you please explain more about this? Are you looking for this code?
Outlook.Folder folder= this.Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts) as Outlook.Folder;
Outlook.ContactItem ci = folder.Items.Add(Outlook.OlItemType.olContactItem) as Outlook.ContactItem;
ci.FirstName = "...";
...
ci.LastName = "...";
ci.Save();
Best regards,
Bessie
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us. - We are changing the issue type to "General Discussion" because you have not followed up with the necessary information. If you have more time to look at the issue and provide more information, please feel free to change the issue type back to "Question" by opening the Options list at the top of the post window, and changing the type. If the issue is resolved, we will appreciate it if you can share the solution so that the answer can be found and used by other community members having similar questions.
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.


