我正在使用 c# 處理 VSTO Outlook AddIn 項目,并嘗試使用以下方法在 Outlook 中添加 DocumentItem - protected void CreateWordDocument(string strPhysicalFilePath, Outlook.Folder ParentFolder) { Outlook.DocumentItem objDocItem = null; Outlook.Attachment objAtt = null; try { objDocItem = ParentFolder.Items.Add("IPM.Document"); objAtt = objDocItem.Attachments.Add(strPhysicalFilePath, ); objDocItem.Subject = objAtt.FileName; string strFileType = Path.GetExtension(strPhysicalFilePath, ); switch (strFileType) { case ".doc": case ".docx": objDocItem.MessageClass = "IPM.Document.Word.Document.8"; break; case ".xls": case ".xlsx": objDocItem.MessageClass = "IPM.Document.Excel.Sheet.8"; break; case ".pps": case ".ppt": case ".pptx": objDocItem.MessageClass = "IPM.Document.PowerPoint.Show.8"; break; case ".txt": objDocItem.MessageClass = "IPM.document.txtfile"; break; } objDocItem.Save(); } catch (Exception ex) { ErrorLog.WriteError("ClassName", "CreateWordDocument()", ex.Message); } finally { if (objDocItem != null) Marshal.ReleaseComObject(objDocItem); if (objAtt != null) Marshal.ReleaseComObject(objAtt); } }但在“ objDocItem = ParentFolder.Items.Add("IPM.Document"); 行出現以下錯誤VSTO Outlook 插件中的 Outlook.Items.Add() 中的操作中止(來自 HRESULT 的異常:0x80004004 (E_ABORT))。相同的代碼在我的計算機上運行良好,但在另一臺計算機上出現此錯誤。
2 回答

搖曳的薔薇
TA貢獻1793條經驗 獲得超6個贊
我找到了解決方案 - 目標平臺 32 位或 64 位存在問題。我在那里遇到異常的機器安裝了 64 位 Office,我的 Outlook 添加安裝程序是在 32 位平臺上構建的。我已經使用 64 位目標平臺重新編譯并構建了 Outlook 添加設置并安裝在該機器上?,F在它工作正常。
- 2 回答
- 0 關注
- 867 瀏覽
添加回答
舉報
0/150
提交
取消