【问题标题】:c# outlook open existing instance and reply to emailc# Outlook 打开现有实例并回复邮件
【发布时间】: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;
        }
    }

【问题讨论】:

    标签: c# .net outlook


    【解决方案1】:

    您似乎对返回桌面上最顶层 Inspector 对象的 ActiveInspector 方法感兴趣。使用此方法访问用户最有可能查看的 Inspector 对象。如果没有检查器处于活动状态,则返回 null(在 VB.NET 中为无)。

    您还可能会发现 Application 类的 Inspectors 属性很有帮助。它返回一个 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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-10-08
      • 1970-01-01
      • 2016-10-16
      • 1970-01-01
      • 1970-01-01
      • 2020-04-22
      • 2015-10-27
      • 2016-05-30
      相关资源
      最近更新 更多