简体   繁体   English

为Outlook 2016创建任务窗格Office加载项

[英]Create Task Pane Office Add-In for Outlook 2016

I am trying to create an add-in for Outlook 2016. In previous versions of Office, this was done using a WinForms UserControl and was fairly simple. 我正在尝试为Outlook 2016创建一个加载项。在以前版本的Office中,这是使用WinForms UserControl完成的,并且非常简单。 However, there are now universal templates in Visual Studio 2015 for an Office Add In , which I would like to use, rather than the Outlook VSTO Add In (both shown here ). 但是,Visual Studio 2015中现在有一个用于Office Add In的通用模板,我想使用它,而不是Outlook VSTO Add In( 这里都显示)。

My issue is that when selecting the new Office Add In template, Visual Studio then asks what application(s) this plug in is for, and as shown, there is not an option for Outlook . 我的问题是,当选择新的Office Add In模板时,Visual Studio会询问此插件所针对的应用程序,如图所示, Outlook没有选项

So, I would like to know how I can create a custom Task Pane for Outlook 2016 using the new Office Templates? 那么,我想知道如何使用新的Office模板为Outlook 2016创建自定义任务窗格?

Apologies for the links to images, I don't yet have enough rep to directly add them to questions. 对于图像链接的道歉,我还没有足够的代表直接将它们添加到问题中。 Thanks! 谢谢!

There is an example solution on GitHub . GitHub上有一个示例解决方案。 In this example, JavaScript and HTML are used. 在此示例中,使用了JavaScript和HTML。 Here is an example of the JavaScript that pulls data from the selected email: 以下是从所选电子邮件中提取数据的JavaScript示例:

  Office.initialize = function (reason) {
    $(document).ready(function () {
        app.initialize();

        loadProps();
    });
};

   function loadProps() {
  var item = Office.context.mailbox.item;

  $('#dateTimeCreated').text(item.dateTimeCreated.toLocaleString());
  $('#dateTimeModified').text(item.dateTimeModified.toLocaleString());
  $('#itemClass').text(item.itemClass);
  $('#itemId').text(item.itemId);
  $('#itemType').text(item.itemType);

  if (item.itemType == Office.MailboxEnums.ItemType.Message){
    loadMessageProps(item);
  }
  else {
    loadAppointmentProps(item);
  }
}

This is then linked to a HTML page to display the data. 然后将其链接到HTML页面以显示数据。 In order to add this to Outlook, there is also an XML manifest file. 为了将其添加到Outlook,还有一个XML清单文件。 This tells outlook where to find the pages, here is a snippet of the file: 这告诉outlook在哪里找到页面,这里是文件的片段:

<Requirements>
  <bt:Sets DefaultMinVersion="1.3">
    <bt:Set Name="Mailbox" />
  </bt:Sets>
</Requirements>
<Hosts>
  <Host xsi:type="MailHost">
    <DesktopFormFactor>
      <!-- Message read form -->
      <ExtensionPoint xsi:type="MessageReadCommandSurface">
        <OfficeTab id="TabDefault">
          <Group id="msgReadDemoGroup">
            <Label resid="groupLabel" />
            <Tooltip resid="groupTooltip" />
            <!-- Task pane button -->
            <Control xsi:type="Button" id="msgReadOpenPaneButton">
              <Label resid="paneReadButtonLabel" />
              <Tooltip resid="paneReadButtonTooltip" />
              <Supertip>
                <Title resid="paneReadSuperTipTitle" />
                <Description resid="paneReadSuperTipDescription" />
              </Supertip>
              <Icon>
                <bt:Image size="16" resid="green-icon-16" />
                <bt:Image size="32" resid="green-icon-32" />
                <bt:Image size="80" resid="green-icon-80" />
              </Icon>
              <Action xsi:type="ShowTaskpane">
                <SourceLocation resid="readTaskPaneUrl" />
              </Action>
            </Control>
          </Group>
        </OfficeTab>
      </ExtensionPoint>

Hope this helps others as it helped me. 希望这有助于其他人帮助我。

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

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