private void AccessContacts(string findLastName)
{
var app = new Microsoft.Office.Interop.Outlook.Application();
Outlook.MAPIFolder folderContacts = app.ActiveExplorer().Session.
GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts);
Outlook.Items searchFolder = folderContacts.Items;
int counter = 0;
foreach (Outlook.ContactItem foundContact in searchFolder)
{
if (foundContact.LastName.Contains(findLastName))
{
foundContact.Display(false);
MessageBox.Show(foundContact.HomeTelephoneNumber.ToString());
counter = counter + 1;
}
}
MessageBox.Show("You have " + counter +
" contacts with last names that contain "
+ findLastName + ".");
}
}