从IMail获取消息的UID,使用javax.mail与IMAP [英] Get UID for message from GMail using javax.mail with IMAP

查看:145
本文介绍了从IMail获取消息的UID,使用javax.mail与IMAP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用javax.mail从IMail中使用IMAP检索邮件。我也想获得应用于每个邮件的标签,所以我正在迭代商店中的所有文件夹(实际上是标签),并相互下载邮件。

I'm using javax.mail to retrieve mails from GMail using IMAP. I want to also obtain the tags being applied to each mail, so I'm iterating over all the folders in the store (which actually are tags) and downloading mails for each other.

我使用的方法是 getUID 获取每个消息的UID,然后比较它们以识别不同文件夹中的相同邮件。

I was using the method getUID of ImapFolder to obtain the UID for each message, and then compare them to recognise the same mail along different folders.

例如,如果我将邮件Hello标记为A和B,我将通过文件夹收件箱,A和B遍历并从每个文件夹获取相同的邮件;所以我可以保留一个标签为Inbox,A和B的单一副本。

For example, if I had the mail "Hello" tagged with "A" and "B", I would iterate through folders "Inbox", "A" and "B" and get the same mail from each folder; so I could keep a single copy tagged with "Inbox", "A" and "B".

然而,getUID方法返回一个文件夹相对的ID,所以相同的邮件可能在不同的文件夹中具有不同的ID,或者不同的邮件可能在不同的文件夹中具有相同的ID。在例子中HellO可能会在A中以邮件1的形式出现,并以B的邮件2的形式出现。

However, the getUID method returns a folder-relative ID, so the same mail may have different IDs in different folders, or different mails may have the same ID in different folders. In the example. "HellO" may appear as mail 1 in "A" and as mail 2 in "B".

有没有办法获取每个邮件的相对商店ID ,独立的文件夹?或者更好地获取附加到单个邮件的标签?

Is there a way of obtaining a store-relative id for each mail, independent of the folder? Or a better way to obtain the tags attached to a single mail?

推荐答案

得到 gmail论坛:有一个 message-id标题,其中包含我正在寻找的值。

Got the answer from gmail forums: there is a "message-id" header that contains the value I was looking for.

这篇关于从IMail获取消息的UID,使用javax.mail与IMAP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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