如何通过 outlook 插件中的 onAppointmentAttendeesChangedHandler 函数获取与会者详细信息

问题描述 投票:0回答:1

我是 outlook 插件的新手。我已根据此链接将我的 Outlook 加载项配置为基于事件的激活https://learn.microsoft.com/en-us/office/dev/add-ins/outlook/autolaunch?tabs=xmlmanifest

当我当时从会议中删除任何人时,我没有在活动中得到他们的名字。我已经提供了代码。

清单.xml

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<OfficeApp xmlns="http://schemas.microsoft.com/office/appforoffice/1.1"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0"
  xmlns:mailappor="http://schemas.microsoft.com/office/mailappversionoverrides/1.0"
  xsi:type="MailApp">
  <Id>37cba818-c575-4ac2-85fe-332d9eae8213</Id>
  <Version>1.0.0.0</Version>
  <ProviderName>Contaso</ProviderName>
  <DefaultLocale>en-US</DefaultLocale>
  <DisplayName DefaultValue="Contaso-outlook-addin" />
  <Description DefaultValue="A template to get started." />
  <IconUrl DefaultValue="https://localhost:3000/assets/icon-64.png" />
  <HighResolutionIconUrl DefaultValue="https://localhost:3000/assets/icon-128.png" />
  <SupportUrl DefaultValue="https://www.contoso.com/help" />
  <AppDomains>
   <AppDomain>https://localhost:3000</AppDomain>
  </AppDomains>
  <Hosts>
    <Host Name="Mailbox" />
  </Hosts>
  <Requirements>
    <Sets>
      <Set Name="Mailbox" MinVersion="1.1" />
    </Sets>
  </Requirements>
  <FormSettings>
    <Form xsi:type="ItemRead">
      <DesktopSettings>
        <SourceLocation DefaultValue="https://localhost:3000/taskpane.html" />
        <RequestedHeight>250</RequestedHeight>
      </DesktopSettings>
    </Form>
  </FormSettings>
  <Permissions>ReadWriteItem</Permissions>
  <Rule xsi:type="RuleCollection" Mode="Or">
    <Rule xsi:type="ItemIs" ItemType="Message" FormType="Read" />
  </Rule>
  <DisableEntityHighlighting>false</DisableEntityHighlighting>
  <VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides"
    xsi:type="VersionOverridesV1_0">
    <VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides/1.1"
      xsi:type="VersionOverridesV1_1">
      <Requirements>
        <bt:Sets DefaultMinVersion="1.10">
          <bt:Set Name="Mailbox" />
        </bt:Sets>
      </Requirements>
      <Hosts>
        <Host xsi:type="MailHost">
          <!-- Event-based activation happens in a lightweight runtime.-->
          <Runtimes>
            <!-- HTML file including reference to or inline JavaScript event handlers.
                 This is used by Outlook on the web and Outlook on the new Mac UI. -->
            <Runtime resid="WebViewRuntime.Url">
              <!-- JavaScript file containing event handlers. This is used by Outlook on Windows. -->
              <Override type="javascript" resid="JSRuntime.Url" />
            </Runtime>
          </Runtimes>
          <DesktopFormFactor>
            <FunctionFile resid="Commands.Url" />
            <ExtensionPoint xsi:type="MessageReadCommandSurface">
              <OfficeTab id="TabDefault">
                <Group id="msgReadGroup">
                  <Label resid="GroupLabel" />
                  <Control xsi:type="Button" id="msgReadOpenPaneButton">
                    <Label resid="TaskpaneButton.Label" />
                    <Supertip>
                      <Title resid="TaskpaneButton.Label" />
                      <Description resid="TaskpaneButton.Tooltip" />
                    </Supertip>
                    <Icon>
                      <bt:Image size="16" resid="Icon.16x16" />
                      <bt:Image size="32" resid="Icon.32x32" />
                      <bt:Image size="80" resid="Icon.80x80" />
                    </Icon>
                    <Action xsi:type="ShowTaskpane">
                      <SourceLocation resid="Taskpane.Url" />
                    </Action>
                  </Control>
                </Group>
              </OfficeTab>
            </ExtensionPoint>

            <!-- Can configure other command surface extension points for add-in command support. -->

            <!-- Enable launching the add-in on the included events. -->
            <ExtensionPoint xsi:type="LaunchEvent">
              <LaunchEvents>

                <LaunchEvent Type="OnAppointmentSend" FunctionName="onAppointmentSendHandler"
                SendMode="PromptUser"
                />

                <LaunchEvent Type="OnAppointmentAttendeesChanged"
                  FunctionName="onAppointmentAttendeesChangedHandler" />

                <LaunchEvent Type="OnAppointmentTimeChanged"
                  FunctionName="onAppointmentTimeChangedHandler" />

                <!-- Other available events -->
                <!--
                <LaunchEvent Type="OnNewMessageCompose" FunctionName="onNewMessageComposeHandler" />
                <LaunchEvent Type="OnNewAppointmentOrganizer"
                  FunctionName="onNewAppointmentComposeHandler" />
                <LaunchEvent Type="OnMessageAttachmentsChanged" FunctionName="onMessageAttachmentsChangedHandler"
                />
                <LaunchEvent Type="OnAppointmentAttachmentsChanged"
                FunctionName="onAppointmentAttachmentsChangedHandler" />
                <LaunchEvent Type="OnMessageRecipientsChanged" FunctionName="onMessageRecipientsChangedHandler" />
                
               
                <LaunchEvent Type="OnAppointmentRecurrenceChanged"
                FunctionName="onAppointmentRecurrenceChangedHandler" />
                <LaunchEvent Type="OnInfoBarDismissClicked" FunctionName="onInfobarDismissClickedHandler" />
                <LaunchEvent Type="OnMessageSend" FunctionName="onMessageSendHandler" SendMode="PromptUser" />
               
                <LaunchEvent Type="OnMessageCompose" FunctionName="onMessageComposeHandler" />
                <LaunchEvent Type="OnAppointmentOrganizer" FunctionName="onAppointmentOrganizerHandler" />
                -->
              </LaunchEvents>
              <!-- Identifies the runtime to be used (also referenced by the Runtime element). -->
              <SourceLocation resid="WebViewRuntime.Url" />
            </ExtensionPoint>
          </DesktopFormFactor>
        </Host>
      </Hosts>
      <Resources>
        <bt:Images>
          <bt:Image id="Icon.16x16" DefaultValue="https://localhost:3000/assets/icon-16.png" />
          <bt:Image id="Icon.32x32" DefaultValue="https://localhost:3000/assets/icon-32.png" />
          <bt:Image id="Icon.80x80" DefaultValue="https://localhost:3000/assets/icon-80.png" />
        </bt:Images>
        <bt:Urls>
          <bt:Url id="Commands.Url" DefaultValue="https://localhost:3000/commands.html" />
          <bt:Url id="Taskpane.Url" DefaultValue="https://localhost:3000/taskpane.html" />
          <bt:Url id="WebViewRuntime.Url" DefaultValue="https://localhost:3000/commands.html" />
          <!-- Entry needed for Outlook on Windows. -->
          <bt:Url id="JSRuntime.Url" DefaultValue="https://localhost:3000/launchevent.js" />
        </bt:Urls>
        <bt:ShortStrings>
          <bt:String id="ActionButton.Label" DefaultValue="Perform an action" />
          <bt:String id="GroupLabel" DefaultValue="Contaso" />
          <bt:String id="TaskpaneButton.Label" DefaultValue="Contaso" />
        </bt:ShortStrings>
        <bt:LongStrings>
          <bt:String id="TaskpaneButton.Tooltip" DefaultValue="Open Contaso Taskpane" />
        </bt:LongStrings>
      </Resources>
    </VersionOverrides>
  </VersionOverrides>
</OfficeApp>

launchevent.js

function onAppointmentSendHandler(event) {
  debugger;
  setSubject(event);
}
function onAppointmentAttendeesChangedHandler(event) {
  setSubject(event);
}

function onAppointmentTimeChangedHandler(event) {
  setSubject(event);
}

function setSubject(event) {
  debugger;
  console.log("event", event);

}
if (Office.context.platform === Office.PlatformType.PC || Office.context.platform == null) {
  Office.actions.associate("onAppointmentSendHandler", onAppointmentSendHandler);
  Office.actions.associate("onAppointmentAttendeesChangedHandler", onAppointmentAttendeesChangedHandler);
  Office.actions.associate("onAppointmentTimeChangedHandler", onAppointmentTimeChangedHandler);
}

现在,当我从约会中删除或添加任何收据时,我没有得到与会者的详细信息。我在调试时附上了函数的图像。 你可以在函数结果中看到我什么也没得到。

我从这里添加了与会者(你可以在图片中看到)。 所以,谁能指导我哪里做错了?

outlook outlook-addin office-addins add-in outlook-web-addins
1个回答
0
投票

您可以使用

Office.context.mailbox.item.requiredAttendees.getAsync
方法调用获得实际值。

表示 RecipientsChangedEventArgs.changedRecipientFields 对象的

Office.RecipientsChangedFields
接口给出了哪些字段已更改的基本信息。在您的场景中,这是
requiredAttendees
,如果所需的与会者已更改则设置。

请注意,您可以在 Tech Community 上发布或投票支持现有功能请求,Office 开发团队在规划过程中会考虑这些请求。

© www.soinside.com 2019 - 2024. All rights reserved.