c# outlook打开现有实例并获取打开的outlook窗口的列表,以便对所选窗口进行回复。
我可以获得outlook的现有实例,但不确定如何接近它的子窗口,并使用现有电子邮件设置回复,而不是创建新的邮件项目
公共静态应用程序{ get { Outlook.Application 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;
}
}发布于 2015-06-02 02:11:07
看起来您对ActiveInspector方法很感兴趣,它返回桌面上最上面的Inspector对象。使用此方法可以访问用户最有可能查看的Inspector对象。如果没有活动的检查器,则返回null (在VB.NET中为Nothing)。
此外,您可能会发现Application类的Inspectors属性很有帮助。它返回一个检查器集合对象,其中包含表示所有打开的检查器的Inspector对象。
Dim myInspectors As Outlook.Inspectors
Dim x as Integer
Dim iCount As Integer
Set myInspectors = Application.Inspectors
iCount = Application.Inspectors.Count
If iCount > 0 Then
For x = 1 To iCount
MsgBox myInspectors.Item(x).Caption
Next x
Else
MsgBox "No inspector windows are open."
End If 如果需要在Outlook Explorer窗口中获取当前选定的项,请使用Selection对象。有关详细信息,请参阅How to: Programmatically Determine the Current Outlook Item。
https://stackoverflow.com/questions/30579056
复制相似问题