如何在 Outlook COM/VSTO 和 Office JS 加载项之间共享用户漫游设置 [英] How to share user roaming settings between Outlook COM/VSTO and Office JS Add-in

查看:15
本文介绍了如何在 Outlook COM/VSTO 和 Office JS 加载项之间共享用户漫游设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在 COM/VSTO Outlook 和 Office JS 加载项之间共享用户的漫游设置和首选项?

解决方案

范围

以下文章介绍了一种让开发人员在 COM/VSTO Outlook 插件和 Office JS 插件之间建立桥梁以共享用户漫游设置和首选项的方法.

简介

有很多公司通过 COM/VSTO Outlook 加载项为他们的客户提供覆盖体验多年,而 Outlook 2000 到最新版本的支持对他们来说是正常的.随着 Microsoft Office 商店的成熟和 Office JS 加载项背后的技术,越来越多的公司希望使用 Office JS API 实施其现有解决方案.能够为 Office 工作的环境编写一次并轻松分发应用程序是非常有吸引力的一点.但是对于仍然使用旧的可靠的 Office 2010 或更旧版本的客户呢?您可能会说:让他们使用我们旧的 COM 加载项,不要回头".那么这可能是有效的,直到该客户开始使用 Outlook for Web 并意识到您也为此环境创建了加载项.伟大的!开始使用它……但是等一下,当使用 Outlook 桌面解决方案时,我在工作场所设置的设置和首选项在哪里?如果我想更改我的偏好怎么办?现在我必须这样做两次?开发人员会说:继续我们的新解决方案,忘记旧的 COM".但是用户可能有一个原因,为什么他们在工作中使用带有 COM 加载项的旧 Outlook 版本,以及远程使用带有新 Office JS 加载项的 OWA(在旅途中、在家工作等).读者现在可能已经明白我的意思了.作为开发人员,您可能希望通过在全新且闪亮的 Office JS 加载项以及旧的但坚固且功能齐全的 COM/VSTO 解决方案之间共享首选项,让这些客户的生活变得更简单.那么,让我们看看如何做到这一点.

Office JS 插件漫游设置

从需求集 1.0 Office JS API

  • https://msdn.microsoft.com/en-us/图书馆/办公室/cc842083.aspx
  • https://msdn.microsoft.com/en-us/library/office/cc842374.aspx?f=255&MSPPError=-2147217396
  • https://msdn.microsoft.com/en-us/图书馆/办公室/cc842386.aspx
  • Is it possible to share user’s roaming settings and preferences between COM/VSTO Outlook and Office JS Add-ins?

    解决方案

    Scope

    The following article covers an approach for developers to make a bridge between COM/VSTO Outlook Add-in and Office JS Add-ins to share user’s roaming settings and preferences.

    Introduction

    There are plenty of companies who deliver reach experience to their customers through COM/VSTO Outlook Add-ins for ages and Outlook 2000 to the latest version support is normal for them. With maturity of the Microsoft Office Store and technology behind Office JS Add-ins more and more companies looking to implement their existing solutions using Office JS API. Ability to write once and distribute easily the application for environments where Office works is very attractive point. But what about customers who still use old reliable Office 2010 or even older. You may say: "Let them use our old COM Add-in and don’t look back". Well this may be valid point until this customer start to use Outlook for Web and realize you’ve created the Add-in for this environment as well. Great! Start using it … but wait a second, where are my settings and preference I set at my work place when used desktop solution for Outlook? What if I would like to change my preferences? Now I have to do that twice? A developer would say: "Move on to our new solution, forget about old COM". But users probably have a reason why they use old Outlook version with COM Add-in at work and OWA with new Office JS Add-in remotely (during a trip, work from home, etc.). The reader probably got my point by now. As the developer, you may want to make life of those customers simpler by sharing the preferences between your brand new and shiny Office JS Add-in as well as your old, but solid and full of features COM/VSTO solution. So, let’s find out how to do that.

    Office JS Add-in Roaming Settings

    Right from the requirement set 1.0 Office JS API RoamingSettings object was introduced with four methods to manipulate with user settings. You are able to set, get and delete any custom value of the user setting/property type of {String|Number|Boolean|Object|Array}. This object keeps those settings per user mailbox and will be available to your Office JS Add-in from any location, device, etc. True roaming to keep your user’s preferences and settings, isn’t it? Please note: You should not use this object to keep sensitive information such as user credential or security tokens. The following example demonstrate usage of the object:

    // Get the current value of the 'myKey' setting
    var value = Office.context.roamingSettings.get('myKey');
    // Update the value of the 'myKey' setting
    Office.context.roamingSettings.set('myKey', 'Hello World!');
    // Persist the change
    Office.context.roamingSettings.saveAsync();
    

    COM/VSTO Add-in for Desktop Outlook

    Let’s return to our COM/VSTO solution. There is the single pre-request: to handle the settings which were stored in the user’s mailbox developer needs to know Office JS Add-in ID as the RoamingSettings are stored per add-in and per user. Well, you would know it indeed, as this is your/your company Add-in. The settings we are looking for are stored in the message property, which is stored in Associated contents table of the Inbox folder may be accessed using IMAPIFolder interface. Wow, this was the key sentence from entire post and needs to be explained in details.
    First you would need to enumerate all messages in associated contents table and find the message with the class "IPM.Configuration.ClientExtension.00000000000000000000000000000000", where zeros must be ID of your Office JS Add-in.



    When message selected, you would need to get "PR_ROAMING_DICTIONARY" Property.


    This property will contain serialized data we stored as roaming setting when used Office JS Add-in in our example above:

    <?xml version="1.0" encoding="utf-8"?>
    <UserConfiguration>
        <Info version="Exchange.12" />
        <Data>
            <e k="18-ExtensionSettings" v="18-{"myKey":""Hello World!""}" />
        </Data>
    </UserConfiguration>
    

    Your COM/VSTO Add-in will be able to read and modify those settings with simple parse. You may want to expose your COM Add-in user setting as well. Usually those settings developers keep in HKCU Windows Registry, to roaming world per user mailbox. The benefit of this not only in capability between Office JS Add-in, but separated set of settings of your Add-in per user mailbox. When those settings created from Desktop Outlook use different info version, for example:

    <Info version="Outlook.16"/>
    

    Conclusion

    As the final note on the topic I would like to illustrate the simple example of shared settings of an application from the same provider where COM and Office JS Add-ins share user settings.


    References

    1. https://dev.outlook.com/reference/add-ins/RoamingSettings.html
    2. https://msdn.microsoft.com/en-us/library/office/cc842083.aspx
    3. https://msdn.microsoft.com/en-us/library/office/cc842374.aspx?f=255&MSPPError=-2147217396
    4. https://msdn.microsoft.com/en-us/library/office/cc842386.aspx

    这篇关于如何在 Outlook COM/VSTO 和 Office JS 加载项之间共享用户漫游设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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