2011-04-15 100 views
0

我正在嘗試設置允許用戶通過我的Web服務 - string subject, DateTime startTime, DateTime dueDate, string body, List<string> recipients, string owner,然後創建Task。這在我的機器上正常工作,但在Windows 2003上,我不斷收到不同的錯誤。目前我越來越 - Runtime.InteropServices.COMException: 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)).Outlook Web服務調用

我正在使用電子郵件訪問帳戶,並已在框中運行。我不確定這是做這件事的最好方法,但這是我得到的。並請善待 - 我是一個.NET Web開發人員,而不是任何Outlook程序員。

我的代碼看起來是這樣的 -

Outlook task = new Outlook(); 
      TaskItem taskItem = (TaskItem)_application.CreateItem(OlItemType.olTaskItem); 
      taskItem.Subject = subject; 
      taskItem.StartDate = startTime; 
      taskItem.DueDate = dueDate; 
      taskItem.Body = body; 
      foreach (string recipient in recipients) 
      { 
       taskItem.Recipients.Add(recipient); 
      }    
      taskItem.Owner = owner; 
      taskItem.Assign(); 
      task.EntryId = taskItem.EntryID; 
      if (taskItem.Saved) 
      { 
       task.Successful = true; 
      } 
      return task; 

回答

0

類ID {0006F03A-0000-0000-C000-000000000046}是Microsoft Office互操作組件的Outlook這是Microsoft Office PIAs的一部分的類ID。您需要在服務器上安裝Microsoft Office PIA,然後才能使用.NET Office互操作性。

這是一個下載鏈接爲Office 2010:http://www.microsoft.com/downloads/en/details.aspx?FamilyID=938fe8ad-583b-4bd7-a345-23250dc15855

如果您正在使用Visual Studio 2010中你可能嵌入PIA的,直接在自己組裝,而不是安裝在PIA的在服務器上的。爲此,請在VS2010中的「Microsoft.Office.Interop.Outlook」參考的「屬性」窗口中找到「Embed Interop Types」並將其設置爲「true」。

+0

已設置爲True。我在服務器上安裝了Office 2007。我會檢查你推薦的PIA。謝謝。 – Merds 2011-04-18 14:50:43

0

我不知道它是安裝在服務器上的不同版本的辦公室嗎?我有一個Web應用程序在服務器上創建Word文檔,這次服務器將Office 2003兼容性作爲組策略的一部分。糟糕的事情發生了,無論如何,卸載它,一切都很好!

+0

我正在使用Office Interop版本11.0.0.0,不確定我是否在服務器上有14個或11個。任何人都知道如何檢查? – Merds 2011-04-18 14:51:52

0

這些COM錯誤是非常難以調試的,我不知道那是什麼意思。我能夠以幫助的方式提供的所有內容都來自現有項目中的一些代碼,它們在Outlook 2007中成功創建任務。這些代碼來自基於VSTO的應用程序。

  Dim task As Outlook.TaskItem = DirectCast(Application.CreateItem(Outlook.OlItemType.olTaskItem), Outlook.TaskItem) 
      task.DueDate = Date.Parse(activity.ActDate) 
      task.StartDate = task.DueDate 
      task.Subject = String.Format(subjectText, activity.AppID) 
      task.Body = String.Format(bodyText, activity.AppID, activity.FileNum, activity.AppID) 
      task.ReminderTime = Now.AddMinutes(10) 
      task.ReminderSet = True 
      task.Categories = CATEGORY_TEST 
      task.Save() 
      task.Close(OlInspectorClose.olDiscard) 
      Marshal.ReleaseComObject(task)