选择了多个日历事件的 Outlook 上下文菜单

Outlook context menu with multiple calendar events selected

我正在用 VS2017 编写 outlook 插件。选择1个或更多日历事件时,我需要出现上下文菜单。当使用以下 XML:

选择单个日历事件时,我可以获得一个上下文菜单
<customUI onLoad="Ribbon_Load" xmlns="http://schemas.microsoft.com/office/2009/07/customui" loadImage="GetImage">
  <contextMenus>    
    <contextMenu idMso="ContextMenuCalendarItem">
        <button id="MyContextMenuCalendarItem"
            label="Copy To Google Calendar"
            image="Google_Calendar_Logo.png"
            onAction="CopyToGoogleCalendar_Click"/>
    </contextMenu>  
    </contextMenus>     
</customUI>

如果我使用IDMSO "ContextMenuMultipleItems",则选择任何类型的多个(电子邮件,日历等)时,将出现上下文菜单。对于选择了多个日历事件的上下文菜单,我无法找出正确的 idMso。

如有任何帮助,我们将不胜感激。

事实证明,使用 "ContextMenuMultipleItems" idMso 可以与添加的 "getVisible" 方法一起使用。我的 XML 现在看起来像:

<?xml version="1.0" encoding="utf-8"?>
<customUI onLoad="Ribbon_Load" xmlns="http://schemas.microsoft.com/office/2009/07/customui" loadImage="GetImage">
  <contextMenus>    
    <contextMenu idMso="ContextMenuCalendarItem">
        <button id="MyContextMenuCalendarItem"
            label="Copy To Google Calendar"
                        image="Google_Calendar_Logo.png"
            onAction="CopyToGoogleCalendar_Click"/>
    </contextMenu>  
    <contextMenu idMso="ContextMenuMultipleItems">
        <button id="MyContextMenuMultipleItems" 
            label="Copy To Google Calendar" 
                        image="Google_Calendar_Logo.png"
                        getVisible="ContextMenuMultipleItems_IsVisible"
            onAction="CopyToGoogleCalendar_Click"/>
    </contextMenu>   
    </contextMenus>     
</customUI>

而 ContextMenuMultipleItems_IsVisible 看起来像:

public bool ContextMenuMultipleItems_IsVisible(Office.IRibbonControl control)
{
    if (control.Context is Outlook.Selection)
    {
        Outlook.Selection selection = control.Context as Outlook.Selection;
        if (selection[1] is Outlook.AppointmentItem)
            return true;
    }
    return false;
}