2016-04-27 217 views
2

尝试使用asp.net/C#通过我的事件注册应用程序向Outlook日历添加事件。尝试初始化(第1行)时,调用被调用者错误拒绝。我如何解决这个问题?C#Outlook - 呼叫被拒绝的呼叫

错误: “检索COM类工厂具有CLSID部件{0006F03A-0000-0000-C000-000000000046}失败,原因是以下错误:80010001呼叫由被叫方拒绝(从HRESULT异常:0x80010001(RPC_E_CALL_REJECTED ))“。办公室

Outlook.Application outlookapp = new Outlook.Application(); 
Outlook.AppointmentItem appt = outlookapp.CreateItem(Outlook.OlItemType.olAppointmentItem) as Outlook.AppointmentItem; 
appt.Subject = er.Event.Name; 
appt.MeetingStatus = Outlook.OlMeetingStatus.olMeeting; 
appt.Location = er.Event.LocationName; 
appt.Start = er.Event.StartTime; 
appt.End = er.Event.EndTime; 
appt.Recipients.ResolveAll(); 
appt.Display(false); 
appt.Save(); 
+0

您是否正在构建与您运行的机器相同的架构?这意味着如果你使用的是64位操作系统,你会编译为x64吗? – pay

+0

我将有效的解决方案平台设置为Any CPU。 – Ram

+0

我通常不会使用该设置的任何真正原因。将其设置为x64或x86,无论您在哪个平台上运行。 – pay

回答

2

首先,你不能从一个服务(如IIS)使用Outlook。其次,即使你的代码工作,你最终会创建一个约会,并在服务器机器上本地显示(!)它,在那里没有人看到它。

创建一个iCal文件,并提供一个链接到用户 - ics文件将在客户端机器上使用Outlook打开,用户将能够保存它。

0

服务器端自动化不支持

Developers can use Automation in Microsoft Office to build custom solutions that use the capabilities and the features that are built into the Office product. Although such programmatic development can be implemented on a client system with relative ease, a number of complications can occur if Automation takes place from server-side code such as Microsoft Active Server Pages (ASP), ASP.NET, DCOM, or a Windows NT service.

参见:https://support.microsoft.com/en-ca/kb/257757