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

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

问题描述

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

Is it possible to share user’s roaming settings and preferences between COM/VSTO Outlook and Office JS Add-ins?

推荐答案

范围

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

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.

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

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.

从需求集1.0开始,Office JS API RoamingSettings 对象是引入了四种使用用户设置进行操作的方法.您可以设置,获取和删除{String | Number | Boolean | Object | Array}的用户设置/属性类型的任何自定义值.该对象保留每个用户邮箱的那些设置,并且可以从任何位置,设备等对您的Office JS外接程序使用.是真正的漫游,用于保留用户的首选项和设置,不是吗?请注意:请勿使用此对象保留敏感信息,例如用户凭证或安全令牌.下面的示例演示该对象的用法:

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();

用于台式机Outlook的COM/VSTO加载项

让我们回到我们的COM/VSTO解决方案.只有一个预先请求:要处理存储在用户邮箱中的设置,开发人员需要知道Office JS加载项ID为消息属性中,存储在收件箱"文件夹的关联的内容表中使用 IMAPIFolder 接口访问.哇,这是整篇文章中的关键句子,需要详细解释.
首先,您需要枚举关联的内容表中的所有消息,并找到带有"IPM.Configuration.ClientExtension.0000000000000000000000000000000000"类的消息,其中零必须是Office JS加载项的ID.



选择消息后,您将需要获取"PR_ROAMING_DICTIONARY"属性.


在上面的示例中使用Office JS加载项时,此属性将包含我们存储为漫游设置的序列化数据:

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>

您的COM/VSTO加载项将能够通过简单的解析来读取和修改这些设置.您可能还希望公开您的COM加载项用户设置.通常,这些设置开发人员保留在HKCU Windows注册表中,以漫游每个用户邮箱的世界.这样做的好处不仅在于Office JS加载项之间的功能,而且还包括每个用户邮箱的独立加载项设置集.当从Desktop Outlook创建的设置使用其他信息版本时,例如:

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"/>

结论

作为该主题的最后注解,我想说明来自同一提供者的应用程序共享设置的简单示例,其中COM和Office JS加载项共享用户设置.


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.


  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
  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天全站免登陆