C#Outlook打开现有实例并回复电子邮件 [英] c# outlook open existing instance and reply to email

查看:205
本文介绍了C#Outlook打开现有实例并回复电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

c#Outlook打开现有实例,并获取已打开的Outlook窗口的列表,以组成对所选窗口的答复.

c# outlook open existing instance and get list of opened outlook windows to compose reply to of chosen window.

我能够获取Outlook的现有实例,但不确定如何访问其子窗口并设置对现有电子邮件的回复,而不是创建新的mailitem

i am able to get outlook's existing instance but not sure how to approach its child windows and set reply to with existing email rather creating new mailitem

公共静态Outlook.Application OutlookInstance { 得到 { Outlook.Application application = null;

public static Outlook.Application OutlookInstance { get { Outlook.Application 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;
        }
    }

推荐答案

您似乎对

It looks like you are interested in the ActiveInspector method which return the topmost Inspector object on the desktop. Use this method to access the Inspector object that the user is most likely to be viewing. If no inspector is active, returns null (Nothing in VB.NET).

此外,您还可以找到 Application类的Inspectors 属性很有帮助.它返回一个Inspectors集合对象,其中包含代表所有打开的检查器的Inspector对象.

Also you may find the Inspectors property of the Application class helpful. It returns an Inspectors collection object that contains the Inspector objects representing all open inspectors.

 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对象.请参阅如何:以编程方式确定当前Outlook项目以获取更多信息.

If you need to get the currently selected items in the Outlook Explorer window use the Selection object. See How to: Programmatically Determine the Current Outlook Item for more information.

这篇关于C#Outlook打开现有实例并回复电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆