【发布时间】:2015-08-15 05:46:33
【问题描述】:
c# Outlook 打开现有实例并获取打开的 Outlook 窗口列表以撰写所选窗口的回复。
我能够获取 Outlook 的现有实例,但不确定如何处理其子窗口并使用现有电子邮件设置回复而不是创建新邮件项
public static Outlook.Application OutlookInstance { 得到 { Outlook.Application 应用程序 = null;
// Check whether there is an Outlook process running.
if (Process.GetProcessesByName("OUTLOOK").Count() > 0)
{
// If so, use the GetActiveObject method to obtain the process and cast it to an Application object.
application = Marshal.GetActiveObject("Outlook.Application") as Outlook.Application;
}
else
{
// If not, create a new instance of Outlook and log on to the default profile.
application = new Outlook.Application();
Outlook.NameSpace nameSpace = application.GetNamespace("MAPI");
nameSpace.Logon("", "", Missing.Value, Missing.Value);
nameSpace = null;
}
// Return the Outlook Application object.
return application;
}
}
【问题讨论】: