C# 如何从上下文菜单获取Outlook约会

C# 如何从上下文菜单获取Outlook约会,c#,.net,outlook,ms-office,outlook-addin,C#,.net,Outlook,Ms Office,Outlook Addin,我已将ContextMenuItem添加到Outlook约会的ContextMenu中 问题是我不知道如何获取约会对象。如果我得到一个IRibbonControl,其上下文属性应该包含约会,但它包含一个选择。就我所能看到的而言,我无法使用所选内容去赴约 本页是我的来源: 有人知道如何获得约会吗?该对象包含图片上选定的AppointmentItem对象。例如: Object selObject = Selection[1]; if

我已将ContextMenuItem添加到Outlook约会的ContextMenu中

问题是我不知道如何获取约会对象。如果我得到一个IRibbonControl,其上下文属性应该包含约会,但它包含一个选择。就我所能看到的而言,我无法使用所选内容去赴约

本页是我的来源:

有人知道如何获得约会吗?

该对象包含图片上选定的AppointmentItem对象。例如:

                Object selObject = Selection[1];
                if (selObject is Outlook.MailItem)
                {
                    Outlook.MailItem mailItem =
                        (selObject as Outlook.MailItem);
                    itemMessage = "The item is an e-mail message." +
                        " The subject is " + mailItem.Subject + ".";
                    mailItem.Display(false);
                }
                else if (selObject is Outlook.ContactItem)
                {
                    Outlook.ContactItem contactItem =
                        (selObject as Outlook.ContactItem);
                    itemMessage = "The item is a contact." +
                        " The full name is " + contactItem.Subject + ".";
                    contactItem.Display(false);
                }
                else if (selObject is Outlook.AppointmentItem)
                {
                    Outlook.AppointmentItem apptItem =
                        (selObject as Outlook.AppointmentItem);
                    itemMessage = "The item is an appointment." +
                        " The subject is " + apptItem.Subject + ".";
                }
                else if (selObject is Outlook.TaskItem)
                {
                    Outlook.TaskItem taskItem =
                        (selObject as Outlook.TaskItem);
                    itemMessage = "The item is a task. The body is "
                        + taskItem.Body + ".";
                }
                else if (selObject is Outlook.MeetingItem)
                {
                    Outlook.MeetingItem meetingItem =
                        (selObject as Outlook.MeetingItem);
                    itemMessage = "The item is a meeting item. " +
                         "The subject is " + meetingItem.Subject + ".";
                }
有关详细信息,请参阅。

该对象包含在图片上选择的AppointmentItem对象。例如:

                Object selObject = Selection[1];
                if (selObject is Outlook.MailItem)
                {
                    Outlook.MailItem mailItem =
                        (selObject as Outlook.MailItem);
                    itemMessage = "The item is an e-mail message." +
                        " The subject is " + mailItem.Subject + ".";
                    mailItem.Display(false);
                }
                else if (selObject is Outlook.ContactItem)
                {
                    Outlook.ContactItem contactItem =
                        (selObject as Outlook.ContactItem);
                    itemMessage = "The item is a contact." +
                        " The full name is " + contactItem.Subject + ".";
                    contactItem.Display(false);
                }
                else if (selObject is Outlook.AppointmentItem)
                {
                    Outlook.AppointmentItem apptItem =
                        (selObject as Outlook.AppointmentItem);
                    itemMessage = "The item is an appointment." +
                        " The subject is " + apptItem.Subject + ".";
                }
                else if (selObject is Outlook.TaskItem)
                {
                    Outlook.TaskItem taskItem =
                        (selObject as Outlook.TaskItem);
                    itemMessage = "The item is a task. The body is "
                        + taskItem.Body + ".";
                }
                else if (selObject is Outlook.MeetingItem)
                {
                    Outlook.MeetingItem meetingItem =
                        (selObject as Outlook.MeetingItem);
                    itemMessage = "The item is a meeting item. " +
                         "The subject is " + meetingItem.Subject + ".";
                }

有关更多信息,请参阅。

不要使用资源管理器。在弹出菜单事件处理程序中选择-可以选择一条消息,然后右键单击另一条消息而不选择它。Explorer.Selection集合不会更改,Explorer.SelectionChange事件也不会激发


处理事件处理程序时,上下文参数将传递给您。将其强制转换为选择对象并使用它。该集合将不同于Explorer.Selection对象。

不要使用弹出菜单事件处理程序中的Explorer.Selection-可以选择一条消息,然后右键单击另一条消息而不选择它。Explorer.Selection集合不会更改,Explorer.SelectionChange事件也不会激发



处理事件处理程序时,上下文参数将传递给您。将其强制转换为选择对象并使用它。该集合将不同于Explorer.Selection对象。

Explorer.Selection集合不能使用。请看我的答案。Dmitry,实际上我没有建议使用Explorer对象。IRibbonControl的Context属性用于根据初始帖子中显示的代码获取选择对象。你为什么会想到资源管理器?你回复中的链接使用了Explorer.Selection。它只是描述了选择对象。。。无论如何,我认为作者知道获取选择对象的正确方法。不能使用Explorer.Selection集合。请看我的答案。Dmitry,实际上我没有建议使用Explorer对象。IRibbonControl的Context属性用于根据初始帖子中显示的代码获取选择对象。你为什么会想到资源管理器?你回复中的链接使用了Explorer.Selection。它只是描述了选择对象。。。无论如何,我认为作者知道获取选择对象的正确方法。代码中使用IRibbonControl.Context属性来获取选择对象。在哪里?我在原始问题或您的答案中没有看到它。请查看SendToGogle方法。很抱歉,我可能是瞎了-您在SendToGogle中看到了什么?IRibbonControl.Context属性用于获取选择对象。我错了吗?代码中使用了IRibbonControl.Context属性来获取选择对象。在哪里?我在原始问题或您的答案中没有看到它。请查看SendToGogle方法。很抱歉,我可能是瞎了-您在SendToGogle中看到了什么?IRibbonControl.Context属性用于获取选择对象。我错了吗?