2011-04-15 104 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)