rpaframework icon indicating copy to clipboard operation
rpaframework copied to clipboard

Lookup Error while trying to use list_messages.

Open kskolte2020 opened this issue 3 years ago • 10 comments

Python Version: 3.8.3 rpaframework = 13.1.0

I found error while I was trying to download attachments from mails using RPA.Email.ImapSmtp in Python. Actually, updated the framework to latest version then I was getting error as LookupError: unknown encoding: None. Then I downgraded to v13.0.1 tracking the changes made, however I still got same error. Then finally I downgraded to v12.8.2 and that worked. So I guess there's error in v12.9.0 or in between 12.9.0 - 13.0.1

kskolte2020 avatar Apr 07 '22 12:04 kskolte2020

Can you post example code you were trying to use ?

mikahanninen avatar Apr 07 '22 12:04 mikahanninen

mail = ImapSmtp(smtp_server="smtp.gmail.com", smtp_port=587)
mail.authorize(account=__gmail_account, password=__gmail_password)
if not inbox_folder:
    mails = mail.list_messages(mail_criteria, source_folder='GmailFolderName')
    print(mails)
else:
    mails = mail.list_messages(mail_criteria, source_folder='Inbox')

I tried to print mails variable, but bcz of error it was getting into exception block.

kskolte2020 avatar Apr 07 '22 12:04 kskolte2020

And your mail_criteria is some sort of string ?

mikahanninen avatar Apr 07 '22 12:04 mikahanninen

And what is the specific Python version you are using ? Python version should be determined by x.yz version number like 3.8.7 and not just 3.8 .

mikahanninen avatar Apr 07 '22 12:04 mikahanninen

And your mail_criteria is some sort of string ?

Yes, it's a string.

kskolte2020 avatar Apr 07 '22 15:04 kskolte2020

And what is the specific Python version you are using ? Python version should be determined by x.yz version number like 3.8.7 and not just 3.8 .

My apologies, it's 3.8.3

kskolte2020 avatar Apr 07 '22 15:04 kskolte2020

I run your example with rpaframework versions 13.0.0 and 13.2.0 without problems.

from RPA.Email.ImapSmtp import ImapSmtp
from RPA.Robocorp.Vault import Vault


def list_emails(mail_criteria, inbox_folder=True):
    secrets = Vault().get_secret("gmailtest")
    mail = ImapSmtp(smtp_server="smtp.gmail.com", smtp_port=587)
    mail.authorize(account=secrets["username"], password=secrets["password"])
    if not inbox_folder:
        mails = mail.list_messages(mail_criteria, source_folder="custom name")
        print(mails)
    else:
        mails = mail.list_messages(mail_criteria, source_folder="INBOX")
        print(mails)

def minimal_task():
    list_emails('SUBJECT "New Test Email from Friday 25/MAR/22"')
    print("Done.")

if __name__ == "__main__":
    minimal_task()

mikahanninen avatar Apr 10 '22 17:04 mikahanninen

I run your example with rpaframework versions 13.0.0 and 13.2.0 without problems.

from RPA.Email.ImapSmtp import ImapSmtp
from RPA.Robocorp.Vault import Vault


def list_emails(mail_criteria, inbox_folder=True):
    secrets = Vault().get_secret("gmailtest")
    mail = ImapSmtp(smtp_server="smtp.gmail.com", smtp_port=587)
    mail.authorize(account=secrets["username"], password=secrets["password"])
    if not inbox_folder:
        mails = mail.list_messages(mail_criteria, source_folder="custom name")
        print(mails)
    else:
        mails = mail.list_messages(mail_criteria, source_folder="INBOX")
        print(mails)

def minimal_task():
    list_emails('SUBJECT "New Test Email from Friday 25/MAR/22"')
    print("Done.")

if __name__ == "__main__":
    minimal_task()

It happened for me in few set of mail criteria, not all, however after downgrade that worked without errors

kskolte2020 avatar Apr 12 '22 13:04 kskolte2020

What kind of criteria do you mean?

mikahanninen avatar Apr 14 '22 10:04 mikahanninen

What kind of criteria do you mean?

I got error in this two example criteria: 'Subject "Invoice" Subject "My Company" Unseen' and 'Subject "Invoice" Subject "My Industries & Co" Unseen'

kskolte2020 avatar Apr 14 '22 10:04 kskolte2020

Please re-open if the issue still exists.

tonnitommi avatar Apr 19 '23 07:04 tonnitommi