简体   繁体   English

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

[英]Outlook context menu with multiple calendar events selected

I'm writing an outlook Add-In in VS2017. 我在VS2017中编写一个Outlook加载项。 I need a context menu to appear when 1 or more calendar events are selected. 当选择1个或多个日历事件时,我需要显示一个上下文菜单。 I can get a context menu to appear when a single calendar event is selected with the following XML: 当使用以下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>

If I use the idMso "ContextMenuMultipleItems", the context menu will appear when multiple of any type (email, calendar, etc.) is selected. 如果我使用idMso“ ContextMenuMultipleItems”,则在选择任何类型的多个(电子邮件,日历等)时,将显示上下文菜单。 I can not figure out the correct idMso for context menu with multiple calendar events selected. 我无法为选择了多个日历事件的上下文菜单找出正确的idMso。

Any help would be greatly appreciated. 任何帮助将不胜感激。

Turns out that using the "ContextMenuMultipleItems" idMso works with the added "getVisible" method. 事实证明,使用“ ContextMenuMultipleItems” idMso可以与添加的“ getVisible”方法一起使用。 My XML now looks like: 我的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>

and the ContextMenuMultipleItems_IsVisible looks like: 和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;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM