简体   繁体   中英

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

  1. You can use Message-Id field of the mail header. Message-Id field for both the mail will be same.

  2. Apply SEARCH command on All Mail Folder. ie search on title --> it will give you uid 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.

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