Hi,
Im trying to get all the contacts that I have in outlook and writing them to a textbox.
This is my code:
// Obtain an instance of the Outlook applicationMicrosoft.Office.Interop.Outlook.Application app = new Microsoft.Office.Interop.Outlook.Application();
// Access the MAPI namespace
Outlook.NameSpace ns = app.GetNamespace("MAPI");
// Get the user's default contacts folder
Outlook.MAPIFolder contacts = ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts);
// Go through all the folders
foreach (Outlook.Folder folder in contacts.Folders)
{
// Iterate through each contact
for (int i = 1; i < folder.Items.Count + 1; i++)
{
// Get a contact
Outlook.ContactItem contact = (Outlook.ContactItem)folder.Items[i];
// Write contact info to textbox
richTextBox1.Text += folder.AddressBookName.ToString() + " " + contact.EntryID + " " + Environment.NewLine;
}
}
But I only get the contacts in the first folder, where am I going wrong?
Shakti Singh DulawatPosted May 6, 2016, 4:01 AM
Carl-Johan LarssonPosted May 6, 2016, 3:34 AM
Shakti Singh DulawatPosted May 6, 2016, 12:06 AM