我正在扩展我的Outlook加载项功能,该功能可存档特定类型的电子邮件。这需要将电子邮件撰写的收件人字段与应用程序状态this.state
进行比较。
我想添加一个事件处理程序Office.EventType.RecipientsChanged,但这会返回错误。
我在App组件(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版本的问题吗?
答案 0 :(得分:0)
您尝试的特定事件不可用。我在下面粘贴了相同的屏幕截图,这是文档的链接。