2016-04-27 213 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