1
следующего код работает отлично, чтобы получить контакты Outlookполучить прогноз контакт контактной группы в C#
Microsoft.Office.Interop.Outlook.Items OutlookItems;
Microsoft.Office.Interop.Outlook.Application outlookObj = new Microsoft.Office.Interop.Outlook.Application();
MAPIFolder Folder_Contacts = (MAPIFolder)outlookObj.Session.GetDefaultFolder(OlDefaultFolders.olFolderContacts);
OutlookItems = Folder_Contacts.Items;
foreach (ContactItem contact in OutlookItems)
{
Console.WriteLine("FirstName " + contact.FirstName);
}
но когда я создать группу в перспективе и добавить контакт в этой группе и запустить этот код, это порождает error
Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.Office.Interop.Outlook.ContactItem'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{00063021-0000-0000-C000-000000000046}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
Почему это происходит и как его решить ???