简体   繁体   中英

Get UID for message from GMail using javax.mail with 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.

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.

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

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

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”标题,其中包含我正在寻找的值。

我认为唯一的方法是使用您根据邮件头自己计算的哈希值。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM