Get the UID for a message from GMail using javax.mail with IMAP

I use javax.mail to receive emails from GMail using IMAP. I also want to get tags that apply to each mail, so I repeat all the folders in the store (which are actually tags) and upload letters to each other.

I used the getUID ImapFolder method to get the UID for each message and then compare them to recognize the same mail in different folders.

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

However, the getUID method returns the identifier corresponding to the folder, so the same mail can have different identifiers in different folders, or different letters can have the same identifier in different folders. In the example. "HellO" can be displayed as mail 1 in "A" and as mail 2 in "B".

Is there a way to get the storage ID for each mail, regardless of the folder? Or the best way to get tags attached to a single mail?

+3
source share
2 answers

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

+3
source

, - , .

+1

Source: https://habr.com/ru/post/1698491/


All Articles