How to get UID of mail in All Maill folder if I have UID of this mail in inbox using imaplib? (GMail)

StackOverflow https://stackoverflow.com/questions/3958019

  •  08-10-2019
  •  | 
  •  

Pergunta

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

Foi útil?

Solução

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. i.e search on title --> it will give you uid for that mail.

Outras dicas

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top