Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Python SyntaxError: invalid syntax (help)

Linh Lee

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



Need help please, fixing invalid syntax error.

CODE:
Python:
from imap_tools import MailBox, A

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


ERROR:
Code:
λ python DeleteEmailFiles.py
  File "C:\Users\Desktop\Desktop\Python Spam Buster\DeleteEmailFiles.py", line 5
    DELETE messages that contains 'a@*.*' in body from Bulk folder
           ^^^^^^^^
SyntaxError: invalid syntax
 
Last edited:
My bad, line needed to be commented out!
New error now:
Code:
λ 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
 
Back
Top Bottom