TypeError: uid is not string ERROR

All other Source.Python topics and issues.
User avatar
Linh_Lee
Junior Member
Posts: 3
Joined: Tue Aug 16, 2022 6:55 pm

TypeError: uid is not string ERROR

Postby Linh_Lee » Sun Aug 28, 2022 5:36 pm

Trying to search/delete for specific user with one letter name, "a", and always changing domains.
Some addresses from this spam:

Code: Select all

a@kragar.imentss.com
a@octobertres.com
a@cngruel.com



Need help please, fixing invalid syntax error.

CODE:

Code: Select all

from imap_tools import MailBox, A
 
with MailBox('imap.mail.yahoo.com').login('name@yahoo.com', 'PWD', 'Bulk') as mailbox:
#    DELETE messages that contains 'a@*.*' in body from Bulk folder
    mailbox.delete(mailbox.fetch(A(body='a@*.*')))


ERROR:

Code: Select all

λ python DeleteEmailFiles.py
Traceback (most recent call last):
  File "C:\Users\Desktop\Desktop\Python Spam Buster\DeleteEmailFiles.py", line 6, in <module>
    mailbox.delete(mailbox.fetch(A(body='a@*.*')))
  File "C:\Users\Desktop\AppData\Local\Programs\Python\Python310\lib\site-packages\imap_tools\mailbox.py", line 176, in delete
    uid_str = clean_uids(uid_list)
  File "C:\Users\Desktop\AppData\Local\Programs\Python\Python310\lib\site-packages\imap_tools\utils.py", line 30, in clean_uids
    raise TypeError('uid "{}" is not string'.format(str(uid)))
TypeError: uid "<imap_tools.message.MailMessage object at 0x000001A96BC7BD90>" is not string

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 7 guests