如何从 ContextMenu 获取 Outlook 约会
How to get Outlook Appointment from ContextMenu
我已将 ContextMenuItem 添加到 Outlook 约会的上下文菜单。
问题是我不知道如何获取 Appointment 对象。如果我得到一个 IRibbonControl,它的 Context 属性 应该包含 Appointment,但它包含一个 Selection。据我所知,我无法使用选择到达约会。
此页面是我的来源:https://msdn.microsoft.com/en-us/library/office/ff863278%28v=office.14%29.aspx
有人知道如何获得预约吗?
Selection 对象包含在图片上选择的 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 + ".";
}
有关详细信息,请参阅 How to: Programmatically Determine the Current Outlook Item。
不要不要 在弹出菜单事件处理程序中使用Explorer.Selection - 可以select消息,然后在不 select 的情况下右键单击另一条消息。 Explorer.Selection 集合不会更改,并且 Explorer.SelectionChange 事件不会触发。
当您处理事件处理程序时,上下文参数将传递给您。将其投射到 Selection 对象并改为使用它。该集合将不同于 Explorer.Selection 对象。
我已将 ContextMenuItem 添加到 Outlook 约会的上下文菜单。
问题是我不知道如何获取 Appointment 对象。如果我得到一个 IRibbonControl,它的 Context 属性 应该包含 Appointment,但它包含一个 Selection。据我所知,我无法使用选择到达约会。
此页面是我的来源:https://msdn.microsoft.com/en-us/library/office/ff863278%28v=office.14%29.aspx
有人知道如何获得预约吗?
Selection 对象包含在图片上选择的 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 + ".";
}
有关详细信息,请参阅 How to: Programmatically Determine the Current Outlook Item。
不要不要 在弹出菜单事件处理程序中使用Explorer.Selection - 可以select消息,然后在不 select 的情况下右键单击另一条消息。 Explorer.Selection 集合不会更改,并且 Explorer.SelectionChange 事件不会触发。
当您处理事件处理程序时,上下文参数将传递给您。将其投射到 Selection 对象并改为使用它。该集合将不同于 Explorer.Selection 对象。