Outlook加载项API不会在Firefox/Chrome上一致地触发ItemChange事件 [英] Outlook Add-In API does not fire the ItemChange event consistently on Firefox/Chrome

查看:95
本文介绍了Outlook加载项API不会在Firefox/Chrome上一致地触发ItemChange事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们已在清单中为Outlook加载项启用了任务窗格固定功能,并注意到除了Windows Outlook 2016客户端之外,现在在线办公室还可以提供固定支持.

We have enabled task pane pinning in our manifest for an Outlook add-in and noticed that the pinning support is now available in the Outlook Office online in addition to the Windows Outlook 2016 client.

但是, ItemChange 事件切换邮件项目时似乎并不会始终被触发(我无法辨别何时触发任何押韵或原因).

However, the ItemChange event does not seem to be triggered consistently when switching mail items (I am unable to discern any rhyme or reason on when it gets fired).

我们正在使用 addHandlerAsync方法.这是一个错误吗?

We are listening for this event using the addHandlerAsync method. Is this a bug?

推荐答案

我遇到了同样的问题.想重新注册事件处理程序并成功了.

I was experiencing the same issue. Thought to re-register the event handler and it worked.

这是我正在使用的代码.

Here is the code I am using.

Office.onReady(function() {
    //console.log('In Office.onReady');

    if(!Office.context.mailbox) {
        console.log('Run inside Outlook to be able to use it.');
        return;
    }
    console.log('Running in Office Add-in');

    // Set up ItemChanged event
    Office.context.mailbox.addHandlerAsync(Office.EventType.ItemChanged, selectedMailItemChanged);
    console.log('Item Change event registered.');

    doSomething(Office.context.mailbox.item);
    //console.log('Page initialized');
});

function selectedMailItemChanged(eventArgs) {
    console.log('Another email message selected');

    if(Office.context.mailbox.item != null) {
        doSomething(Office.context.mailbox.item);
    }
    else {
        console.log('No email is selected.');
        Office.context.mailbox.removeHandlerAsync(Office.EventType.ItemChanged, {handler: selectedMailItemChanged}, function(result) {
            console.log('Item Change event unregistered.');
            Office.context.mailbox.addHandlerAsync(Office.EventType.ItemChanged, selectedMailItemChanged);
            console.log('Item Change event re-registered.');
        });
    }
}

function doSomething(item) {
    // do something.
}

但是,在另一种情况下,您可以在外接程序仍处于打开状态时从外接程序导航到另一个网页,请参见

However, in another case where you can navigate to another web-page from within your add-in, while the add-in was still open, see this answer.

这篇关于Outlook加载项API不会在Firefox/Chrome上一致地触发ItemChange事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆