How to get UID of mail in All Maill folder if I have UID of this mail in inbox using imaplib? (GMail)
How to get UID of mail in All Maill fol开发者_开发知识库der if I have UID of this mail in inbox using imaplib? As you know the google store mails in the two instances in All Mail and in inbox I whant to move this to mail in trash folder using imaplib
You can do it using any of the 2 following ways.
You can use
Message-Id
field of the mail header.Message-Id
field for both the mail will be same.Apply
SEARCH
command onAll Mail
Folder. i.e search on title --> it will give youuid
for that mail.
It can be done by searching with X-GM-MSGID over ALLMail folder.
Message X-GM-MSGID is unique across all folders in Gmail. So You just need to fetch X-GM-MSGID of email in INBOX along with UID.
Now You need to search with X-GM-MSGID on AllMail folder like this
UID SEARCH X-GM-MSGID 1278455344230334865
You can find more details here https://developers.google.com/google-apps/gmail/imap_extensions#access_to_the_gmail_unique_message_id_x-gm-msgid
I don't think imap lib supports Gmail enhanched capabulities. You may need to extend the imap library with the Gmail specific commands.
精彩评论