2 回答

TA貢獻1811條經驗 獲得超5個贊
您沒有在代碼中添加正確的使用。您需要添加:
using Microsoft.Office.Interop.Outlook;
如果沒有這一行,您應該在互操作庫中的每個對象之前鍵入完整的命名空間。使用到位后,您可以刪除來Outlook.自互操作的所有對象。但是創建主 Application 對象需要完整的命名空間,以避免與 Winforms 中定義的 Application 類發生沖突。
Microsoft.Office.Interop.Outlook.Application outlookApp =
new Microsoft.Office.Interop.Outlook.Application();
_MailItem oMailItem = (_MailItem)outlookApp.CreateItem(OlItemType.olMailItem);
Inspector oInspector = oMailItem.GetInspector;
..... and so on ....

TA貢獻1860條經驗 獲得超8個贊
您似乎已將 Outlook 互操作添加到項目引用中兩次。
至于錯誤信息,你只需要在 Outlook 命名空間中添加一個別名即可:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Outlook = Microsoft.Office.Interop.Outlook;
using Office = Microsoft.Office.Core;
此外,您可能會發現C# 應用程序自動化 Outlook (CSAutomateOutlook)示例項目很有幫助。
- 2 回答
- 0 關注
- 141 瀏覽
添加回答
舉報