McFizz
McFizz

Reputation: 3253

How to delete a specific email using only uid

I'm trying to delete an email remotely using python's imap4 library and the email's uid value. I have tried using this code but it hasn't worked.

mail.store(uid,'+FLAGS','\\Deleted')
mail.expunge()

How do I delete this particular email?

Upvotes: 0

Views: 235

Answers (1)

Max
Max

Reputation: 10985

If you're using UIDs, you need to use UID store:

mail.uid('STORE', uid,'+FLAGS','\\Deleted')
mail.expunge()

Don't mix message sequence numbers (fetch, store, search) with UIDs (uid fetch, uid store, uid search). You might delete the wrong message all together!

Upvotes: 1

Related Questions