[英]'System.Runtime.InteropServices.COMException'
我試圖在c#.net應用程序中檢索我的Outlook聯系人。 但是在創建Outlook應用程序的對象時,出現了錯誤
"AnswerWizard = '((Microsoft.Office.Interop.Outlook.ApplicationClass.(outlookObj)).AnswerWizard' threw an exception of type 'System.Runtime.InteropServices.COMException'"
我試圖使用revsvr32“ DLL路徑”注冊dll,但出現模塊加載錯誤,但未找到DLLRegisterServer。
這是我編寫的代碼:
DataSet ds = new DataSet();
ds.Tables.Add("Contacts");
ds.Tables[0].Columns.Add("Email ID");
ds.Tables[0].Columns.Add("FirstName");
ds.Tables[0].Columns.Add("LastName");
Microsoft.Office.Interop.Outlook.Items OutlookItems;
Microsoft.Office.Interop.Outlook.Application outlookObj;
MAPIFolder Folder_Contacts;
outlookObj = new Microsoft.Office.Interop.Outlook.Application();
Folder_Contacts =(MAPIFolder)outlookObj.Session.GetDefaultFolder (OlDefaultFolders.olFolderContacts);
OutlookItems = Folder_Contacts.Items;
for (int i = 0; i < OutlookItems.Count; i++)
{
Microsoft.Office.Interop.Outlook.ContactItem contact =(Microsoft.Office.Interop.Outlook.ContactItem)OutlookItems[i + 1];
DataRow dr = ds.Tables[0].NewRow();
dr[0] = contact.Email1Address;
dr[1] = contact.FirstName;
dr[2] = contact.LastName;
ds.Tables[0].Rows.Add(dr);
if (i == 10)
break;
}
dgvContacts.DataSource = ds.Tables[0];
return ds;
我得到的計數為零。
我認為Application.AnswerWizard從未在Outlook中工作過。 你想做什么?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.