Не удается добавить обработчик асинхронных событий Office.EventType.RecipientsChanged - Outlook, Office.js, React, TypeScript - PullRequest
0 голосов
/ 19 ноября 2018

Я расширяю свою функциональность надстройки Outlook, которая архивирует определенный тип электронной почты.Для этого необходимо сравнить поля получателей из сообщения электронной почты с состоянием приложения this.state.

Я хотел бы добавить обработчик событий Office.EventType.RecipientsChanged, но это возвращает ошибку.

Ошибка консоли

Я создал другое событиеОбработчик в компоненте приложения (mailbox.addHandlerAsync) и работает отлично.Я прилагаю код ниже:

`componentDidMount() {`

// This code works perfectly !

    if (this._isConfigured() && Office.context.mailbox.item.itemType === Office.MailboxEnums.ItemType.Message) {
      if (Office.context.mailbox.item !== undefined) {
        Office.context.mailbox.addHandlerAsync(
          Office.EventType.ItemChanged,
          () => this._parseItem(),
        );
// This handler gives me an error.

        Office.context.mailbox.item.addHandlerAsync(
          Office.EventType.RecipientsChanged,
          () => this._parseItem(), (AsyncResult) => this._handleError(AsyncResult)
          );

// I am using setInterval to cough a change in recipients (cc, bcc, to) email compose form.

        setInterval(this._checkrecipientsOnCompose.bind(this), 5000);
      this._parseItem();
    } else {
      return;
    }}}`

Error:

[Screen Shoot of console error ][1]

  [1]: https://i.stack.imgur.com/5GVZE.png

Надстройка package.json:

`{
    "name": "s_outlook",
    "description": "",
    "author": "",
    "version": "1.0.0",
    "scripts": {
        "clean": "rimraf dist && rimraf .awcache",
        "lint": "tslint --project tsconfig.json",
        "start": "webpack-dev-server --inline --config config/webpack.dev.js --progress",
        "sideload": "office-toolbox sideload -m manifest.xml -a Outlook",
        "build": "npm run clean && webpack --config config/webpack.prod.js --colors --progress --bail",
        "validate": "office-toolbox validate -m manifest.xml"
    },
    "dependencies": {
        "@microsoft/office-js-helpers": "^1.0.1",
        "core-js": "^2.5.3",
        "moment": "2.18.1",
        "office-ui-fabric-react": "^5.51.0",
        "react": "^16.6.3",
        "react-dom": "^16.6.3",
        "sugarcrm-js-rest-consumer": "^1.0.3"
    },
    "devDependencies": {
        "@types/office-js": "^0.0.130",
        "@types/react": "^16.7.6",
        "@types/react-dom": "^16.0.4",
        "@types/react-hot-loader": "^3.0.6",
        "@types/webpack": "2.2.12",
        "@types/webpack-dev-server": "1.12.6",
        "autoprefixer": "6.7.7",
        "copy-webpack-plugin": "4.0.1",
        "css-loader": "0.27.3",
        "extract-text-webpack-plugin": "2.1.0",
        "file-loader": "0.10.1",
        "html-webpack-plugin": "2.28.0",
        "less": "^3.0.1",
        "less-loader": "^4.0.5",
        "office-toolbox": "^0.1.0",
        "postcss-loader": "1.3.3",
        "react-hot-loader": "^3.1.3",
        "rimraf": "2.6.1",
        "style-loader": "0.16.0",
        "ts-loader": "^3.5.0",
        "tslint": "^5.9.1",
        "typescript": "^2.7.2",
        "webpack": "^3.11.0",
        "webpack-dev-server": "^2.11.1",
        "webpack-merge": "^4.1.1"
    }
}`

Манифест xml:

`
<?xml version="1.0" encoding="UTF-8"?>
<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">

  <!-- Begin Basic Settings: Add-in metadata, used for all versions of Office unless override provided. -->

  <!-- IMPORTANT! Id must be unique for your add-in, if you reuse this manifest ensure that you change this id to a new GUID. -->
  <Id></Id>

  <!--Version. Updates from the store only get triggered if there is a version change. -->
  <Version>1.0.0.0</Version>
  <ProviderName>xxx</ProviderName>
  <DefaultLocale>en-US</DefaultLocale>
  <!-- The display name of your add-in. Used on the store and various places of the Office UI such as the add-ins dialog. -->
  <DisplayName DefaultValue="S outlook" />
  <Description DefaultValue="Outlook Add-in for"/>

  <!-- Icon for your add-in. Used on installation screens and the add-ins dialog. -->
  <IconUrl DefaultValue="https://localhost:3000/assets/icon-80.png" />
  <HighResolutionIconUrl DefaultValue="https://localhost:3000/assets/logo-filled.png"/>

  <!--If you plan to submit this add-in to the Office Store, uncomment the SupportUrl element below-->
  <SupportUrl DefaultValue="https://s.co.uk" />

  <!-- Domains that will be allowed when navigating. For example, if you use ShowTaskpane and then have an href link, navigation will only be allowed if the domain is on this list. -->
  <AppDomains>
    <AppDomain>https://candy.ddev.local:3000</AppDomain>
    <AppDomain>AppDomain2</AppDomain>
    <AppDomain>AppDomain3</AppDomain>
  </AppDomains>
  <!--End Basic Settings. -->

  <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/index.html"/>
        <RequestedHeight>350</RequestedHeight>
      </DesktopSettings>
    </Form>
    <Form xsi:type="ItemEdit">
      <DesktopSettings>
        <SourceLocation DefaultValue="https://localhost:3000/index.html"/>
      </DesktopSettings>
    </Form>
  </FormSettings>

  <Permissions>ReadWriteMailbox</Permissions>

  <Rule xsi:type="RuleCollection" Mode="Or">
    <Rule xsi:type="ItemIs" ItemType="Message" FormType="Edit" />
    <Rule xsi:type="ItemIs" ItemType="Message" FormType="Read" />
  </Rule>
  <DisableEntityHighlighting>false</DisableEntityHighlighting>
  <VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides" xsi:type="VersionOverridesV1_0">
    <Requirements>
      <bt:Sets DefaultMinVersion="1.3">
        <bt:Set Name="Mailbox" />
      </bt:Sets>
    </Requirements>
    <Hosts>
      <Host xsi:type="MailHost">

       <DesktopFormFactor>
          <!-- Location of the Functions that UI-less buttons can trigger (ExecuteFunction Actions). -->
        <FunctionFile resid="functionFile" />
          <!-- Message Read -->
          <ExtensionPoint xsi:type="MessageReadCommandSurface">
            <!-- Use the default tab of the ExtensionPoint or create your own with <CustomTab id="myTab"> -->
            <OfficeTab id="TabDefault">
              <!-- Up to 6 Groups added per Tab -->
              <Group id="msgReadGroup">
                <Label resid="groupLabel" />
                <!-- Launch the add-in : task pane button -->
                <Control xsi:type="Button" id="msgReadOpenPaneButton">
                  <Label resid="paneReadButtonLabel" />
                  <Supertip>
                    <Title resid="paneReadSuperTipTitle" />
                    <Description resid="paneReadSuperTipDescription" />
                  </Supertip>
                  <Icon>
                    <bt:Image size="16" resid="icon16" />
                    <bt:Image size="32" resid="icon32" />
                    <bt:Image size="80" resid="icon80" />
                  </Icon>
                  <Action xsi:type="ShowTaskpane">
                    <SourceLocation resid="messageReadTaskPaneUrl" />
                  </Action>
                </Control>
                <!-- Go to http://aka.ms/ButtonCommands to learn how to add more Controls: ExecuteFunction and Menu -->
              </Group>
            </OfficeTab>
          </ExtensionPoint>
          <!-- Go to http://aka.ms/ExtensionPointsCommands to learn how to add more Extension Points: MessageRead, AppointmentOrganizer, AppointmentAttendee -->
        </DesktopFormFactor>
      </Host>
    </Hosts>
    <Resources>
      <bt:Images>
        <bt:Image id="icon16" DefaultValue="https://localhost:3000/assets/icon-16.png"/>
        <bt:Image id="icon32" DefaultValue="https://localhost:3000/assets/icon-32.png"/>
        <bt:Image id="icon80" DefaultValue="https://localhost:3000/assets/icon-80.png"/>
      </bt:Images>
      <bt:Urls>
        <bt:Url id="functionFile" DefaultValue="https://localhost:3000/function-file/function-file.html"/>
        <bt:Url id="messageReadTaskPaneUrl" DefaultValue="https://localhost:3000/index.html"/>
      </bt:Urls>
      <bt:ShortStrings>
          <bt:String id="groupLabel" DefaultValue="My S CRM Group"/>
          <bt:String id="customTabLabel"  DefaultValue="My S CRM Tab"/>
          <bt:String id="paneReadButtonLabel" DefaultValue="S CRM"/>
          <bt:String id="paneReadSuperTipTitle" DefaultValue="S CRM"/>
          <bt:String id="paneComposeButtonLabel" DefaultValue="S CRM"/>
      </bt:ShortStrings>
      <bt:LongStrings>
        <bt:String id="paneReadSuperTipDescription" DefaultValue="Opens a pane displaying all available properties. This is an example of a button that opens a task pane."/>
      </bt:LongStrings>
    </Resources>
    <VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides/1.1" xsi:type="VersionOverridesV1_1">
      <Requirements>
        <bt:Sets DefaultMinVersion="1.7">
          <bt:Set Name="Mailbox" />
        </bt:Sets>
      </Requirements>
      <Hosts>
        <Host xsi:type="MailHost">
          <DesktopFormFactor>
            <!-- Location of the Functions that UI-less buttons can trigger (ExecuteFunction Actions). -->
            <FunctionFile resid="residUILessFunctionFileUrl" />
            <!-- The functionfile and function name to call on message send.  -->
            <!-- In this particular case the function validateBody will be called within the JavaScript code referenced in residUILessFunctionFileUrl. -->
            <ExtensionPoint xsi:type="Events">
              <!-- information about this extension point -->
              <Event Type="ItemSend" FunctionExecution="synchronous" FunctionName="itemSendHandler" />
            </ExtensionPoint>
            <!-- Message Compose -->
            <ExtensionPoint xsi:type="MessageComposeCommandSurface">
              <OfficeTab id="TabDefault">
                <Group id="msgComposeGroup">
                  <Label resid="groupLabel" />
                  <Control xsi:type="Button" id="msgComposeOpenPaneButton">
                    <Label resid="paneComposeButtonLabel" />
                    <Supertip>
                        <Title resid="paneReadSuperTipTitle" />
                        <Description resid="paneReadSuperTipDescription" />
                    </Supertip>
                    <Icon>
                      <bt:Image size="16" resid="icon16" />
                      <bt:Image size="32" resid="icon32" />
                      <bt:Image size="80" resid="icon80" />
                    </Icon>
                    <Action xsi:type="ShowTaskpane">
                      <SourceLocation resid="MessageComposeCommandSurface" />
                      <SupportsPinning>true</SupportsPinning>
                    </Action>
                  </Control>
                </Group>
              </OfficeTab>
            </ExtensionPoint>
            <!-- Message Read -->
            <ExtensionPoint xsi:type="MessageReadCommandSurface">
              <!-- Use the default tab of the ExtensionPoint or create your own with <CustomTab id="myTab"> -->
              <OfficeTab id="TabDefault">
                <!-- Up to 6 Groups added per Tab -->
                <Group id="msgReadGroup">
                  <Label resid="groupLabel" />
                  <!-- Launch the add-in : task pane button -->
                  <Control xsi:type="Button" id="msgReadOpenPaneButton">
                    <Label resid="paneReadButtonLabel" />
                    <Supertip>
                      <Title resid="paneReadSuperTipTitle" />
                      <Description resid="paneReadSuperTipDescription" />
                    </Supertip>
                    <Icon>
                      <bt:Image size="16" resid="icon16" />
                      <bt:Image size="32" resid="icon32" />
                      <bt:Image size="80" resid="icon80" />
                    </Icon>
                    <Action xsi:type="ShowTaskpane">
                      <SourceLocation resid="messageReadTaskPaneUrl" />
                      <SupportsPinning>true</SupportsPinning>
                    </Action>
                  </Control>
                  <!-- Go to http://aka.ms/ButtonCommands to learn how to add more Controls: ExecuteFunction and Menu -->
                </Group>
              </OfficeTab>
            </ExtensionPoint>
            <!-- Go to http://aka.ms/ExtensionPointsCommands to learn how to add more Extension Points: MessageRead, AppointmentOrganizer, AppointmentAttendee -->
          </DesktopFormFactor>
        </Host>
      </Hosts>
      <Resources>
        <bt:Images>
          <bt:Image id="icon16" DefaultValue="https://localhost:3000/assets/icon-16.png"/>
          <bt:Image id="icon32" DefaultValue="https://localhost:3000/assets/icon-32.png"/>
          <bt:Image id="icon80" DefaultValue="https://localhost:3000/assets/icon-80.png"/>
        </bt:Images>
        <bt:Urls>
          <bt:Url id="residUILessFunctionFileUrl" DefaultValue="https://localhost:3000/function-file/function-file.html"/>
          <bt:Url id="messageReadTaskPaneUrl" DefaultValue="https://localhost:3000/index.html"/>
          <bt:Url id="MessageComposeCommandSurface" DefaultValue="https://localhost:3000/index.html"/>
        </bt:Urls>
        <bt:ShortStrings>
          <bt:String id="groupLabel" DefaultValue="My S CRM Group"/>
          <bt:String id="customTabLabel"  DefaultValue="My S CRM Tab"/>
          <bt:String id="paneReadButtonLabel" DefaultValue="S CRM"/>
          <bt:String id="paneReadSuperTipTitle" DefaultValue="S CRM"/>
          <bt:String id="paneComposeButtonLabel" DefaultValue="S CRM"/>
        </bt:ShortStrings>
        <bt:LongStrings>
          <bt:String id="paneReadSuperTipDescription" DefaultValue="Opens a pane displaying all available properties. This is an example of a button that opens a task pane."/>
        </bt:LongStrings>
      </Resources>
    </VersionOverrides>
  </VersionOverrides>
</OfficeApp>
'

Это проблема?с версией API?

1 Ответ

0 голосов
/ 14 декабря 2018

Конкретное событие, которое вы пытаетесь, недоступно.Я вставил скриншот того же самого ниже и вот ссылка на документацию.

https://docs.microsoft.com/en-us/javascript/api/outlook_1_7/office.mailbox?view=office-js#method-details

enter image description here

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...