Exchange Web服务获取消息消息ID [英] Exchange Web Services get Message Message-ID

查看:197
本文介绍了Exchange Web服务获取消息消息ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Java EWS库尝试同步来自Exchange邮箱的邮件。我能够获取自上次同步日期以来创建的所有新消息的列表,但是,我真的想找出消息ID 属性。

I'm using the Java EWS library to try to sync messages from an Exchange mailbox. I'm able to get a list off all new messages created since the last sync date, however, I would really like to find out the Message-ID property of the message before loading it from exchange.

背景:我正在尝试将EWS同步集成到现有的邮件存储系统中。 Message-ID标识仅出于性能原因,因为我们的系统已经在EWS之外处理了数百万条消息。必须再次下载它们会导致主要的性能开销。

Background: I'm trying to integrate EWS sync into an existing mail storage system. The Message-ID identification is solely for performance reasons, as our system already has millions of messaged processed outside of EWS. Having to download them again would cause major performance overhead.

//Sample code to fetch the message from sync

ChangeCollection<ItemChange> icc = service.syncFolderItems( folder.getId()
                    , PropertySet.FirstClassProperties // propertySet
                    , null // ignoredItemIds
                    , 25 // maxChangesReturned
                    , SyncFolderItemsScope.NormalItems
                    , currSyncState );

for ( ItemChange ic : icc )
{
    if (ic.getChangeType() == ChangeType.Create)
    {
        Item item = ic.getItem();
        //how to get the Message-ID
    }

现在,我看到检索Message-ID的最好方法是在调用 ic.load()之后调用 ic.getItem()。getInternetMessageHeaders() / code>。但这需要从交换中加载整个消息,我会避免这一步骤。

Right now, the best way I see to retrieve the Message-ID is by calling ic.getItem().getInternetMessageHeaders() after calling ic.load(). But that requires loading the entire message from exchange, and I would to avoid this step.

编辑:获取消息ID的另一种方法是

Another way to grab the Message-ID is

EmailMessage em = EmailMessage.bind( service, item.getId() );
em.getInternetMessageId()

但是,仍会加载整个邮件。

However, that still loads the entire message.

另一种解决方案是开始通过ItemId关联消息,但即使这样也不完美: http://daniellang.net/exchange-web-services-itemid-is-not-permanent/

The other solution is to start associating messages by the ItemId, but even that's not perfect: http://daniellang.net/exchange-web-services-itemid-is-not-permanent/

有关消息ID的更多信息: http://en.wikipedia.org / wiki / Message-ID

More about Message-ID: http://en.wikipedia.org/wiki/Message-ID

推荐答案

我相信解决方案是:

EmailMessage em = EmailMessage.bind( service, item.getId(),
                   new PropertySet( EmailMessageSchema.InternetMessageId) );

说明:

我们必须绑定将项目发送到电子邮件消息,但我们只通过PropertySet参数询问ID和我们想要的任何其他属性,而不是抓取所有信息。

We have to bind the item to an email message, but instead of grabbing all the info, we only ask for the ID and any additional properties we want through the PropertySet parameter.

灵感来自这个答案: https://stackoverflow.com/a/ 22482779/138228

这篇关于Exchange Web服务获取消息消息ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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