用c#打开一个新的Outlook 2016窗口



我是Visual Studio 2017和c#的新手。我的目标是打开一个新的Outlook窗口,点击一个小程序中的按钮,我写的学习原因。问题是,据我所知,这里的Office API外观不支持Office 2016,或者更确切地说,不支持任何2.0以上的框架我只发现这方面的一个用户的评论有点帮助,但他们也建议Office API不再工作。

我非常感谢每一条有用的评论!

使用哪些Office互操作文件(它们属于哪个Office版本(并不重要,您仍然可以从.Net应用程序自动化Office应用程序。因此,只需将COM引用(用于Microsoft Office Outlook(添加到您的应用程序中,并使用以下代码:

using System;
using System.Runtime.InteropServices;
using Outlook = Microsoft.Office.Interop.Outlook;
using Office = Microsoft.Office.Core;
namespace FileOrganizer
{
class Program
{
private void CreateMailItem()
{            
Outlook.Application app = new Outlook.Application();
Outlook.MailItem mailItem = app.CreateItem(Outlook.OlItemType.olMailItem);
mailItem.Subject = "This is the subject";
mailItem.To = "someone@example.com";
mailItem.Body = "This is the message.";                        
mailItem.Display(false);
}
}
}

相关内容

最新更新