C#调用OutLook组件失败,急求高手诊断。
一个小程序,C#读取本地联系人,在开发环境,和自己公司,一切正常,但是,在客户那边,不行了。可能是客户那边因为PC都在域控制中,所以又权限问题,请教各位有什么解决方法
主要代码如下
Microsoft.Office.Interop.Outlook.Application myOlApp = new Microsoft.Office.Interop.Outlook.ApplicationClass();
Microsoft.Office.Interop.Outlook.NameSpace myNameSpace;
Microsoft.Office.Interop.Outlook.MAPIFolder myFloder;
myNameSpace = myOlApp.GetNamespace("MAPI").Session;
myFloder = myNameSpace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderContacts;
StringBuilder xmlstr = new StringBuilder();
xmlstr.Append("<List>");
foreach (ContactItem foundContact in myFloder.Items)//遍历Outlook
{
if (foundContact.Email1Address.Contains(""))
{
xmlstr.Append("<Info>");
xmlstr.Append("<Account>");
xmlstr.Append(foundContact.Account);
xmlstr.Append("</Account>");
xmlstr.Append("<EntryID>");
xmlstr.Append(foundContact.EntryID);
xmlstr.Append("</EntryID>");
xmlstr.Append("<FirstName>");
xmlstr.Append(foundContact.FirstName);
xmlstr.Append("</FirstName>");
....
xmlstr.Append("</Info>");
}
}
xmlstr.Append("</List>");
....
出错信息
System.InvalidCastException: 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)).at OutlookTest.Program.Main(String[] args)
然后猜想说是权限问题,又以管理员权限运行
出错信息
System.Runtime.InteropServices.COMException (0x80080005): Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80080005 Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)).at OutlookTest.Program.Main(String[] args)
请高手帮个忙
主要代码如下
Microsoft.Office.Interop.Outlook.Application myOlApp = new Microsoft.Office.Interop.Outlook.ApplicationClass();
Microsoft.Office.Interop.Outlook.NameSpace myNameSpace;
Microsoft.Office.Interop.Outlook.MAPIFolder myFloder;
myNameSpace = myOlApp.GetNamespace("MAPI").Session;
myFloder = myNameSpace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderContacts;
StringBuilder xmlstr = new StringBuilder();
xmlstr.Append("<List>");
foreach (ContactItem foundContact in myFloder.Items)//遍历Outlook
{
if (foundContact.Email1Address.Contains(""))
{
xmlstr.Append("<Info>");
xmlstr.Append("<Account>");
xmlstr.Append(foundContact.Account);
xmlstr.Append("</Account>");
xmlstr.Append("<EntryID>");
xmlstr.Append(foundContact.EntryID);
xmlstr.Append("</EntryID>");
xmlstr.Append("<FirstName>");
xmlstr.Append(foundContact.FirstName);
xmlstr.Append("</FirstName>");
....
xmlstr.Append("</Info>");
}
}
xmlstr.Append("</List>");
....
出错信息
System.InvalidCastException: 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)).at OutlookTest.Program.Main(String[] args)
然后猜想说是权限问题,又以管理员权限运行
出错信息
System.Runtime.InteropServices.COMException (0x80080005): Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80080005 Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)).at OutlookTest.Program.Main(String[] args)
请高手帮个忙
...全文
相关推荐
C# Outlook
C#编写的一个Outlook客户端!<br>支持附件!<br>03环境!
C#源码网络操作调用Outlook发送邮件
C#源码网络操作调用Outlook发送邮件
在Outlook中附加文件和创建新邮件
在Outlook中打开“新邮件”窗口并附加项目的代码
vs2008 asp.net 用outlook发邮件
vs2008 asp.net 用outlook发邮件.
VSTO开发Outlook发送超大附件
通过CSDN MSDN等网站资料收集 总算是实验开发出Outlook发送超大附件支持 网盘思路 1:新建AddIn项目 2:增加MailItem的AttachmentAdd事件 通过判断附件大小 小于 Mb 则保存在附件 大于 Mb则后台Post到Web或FTP服务器 并返回连接 4:将连接作为html 的超链接模式<A href "返回值">下载超大附件< A> 并将MailItem的附件Delete掉 5:让OutLook正常发送邮件 ps:本文中后台Post到web或ftp服务器的代码没有 这部分比较简单大家自行发挥哈 由于是领导着急知道测试结果 代码里面比较乱 但可以运行起来 新建邮件超过1Mb的就会有提示 ">通过CSDN MSDN等网站资料收集 总算是实验开发出Outlook发送超大附件支持 网盘思路 1:新建AddIn项目 2:增加MailItem的AttachmentAdd事件 通过判断附件大小 小于 Mb 则保存在附件 大于 Mb则后台Post到Web或FTP服务器 并返回连接 4:将连接作为h [更多]


