I am using IMAPClient in my Django email client, and currently I am trying to fetch UIDs of the first fifty messages in a given mailbox by the following code:
server = IMAPClient(HOST, use_uid=True, ssl=True)
server.login(USERNAME, PASSWORD)
server.select_folder(folder_name)
messages = server.search(['NOT DELETED', '1:50'])
response = server.fetch(messages, ['UID'])
I would expect then to fetch the unique message identifier by the following command:
for data in response.items():
data[b'UID']
but I end up with keyerror - data has no key named 'UID'. What am I doing wrong? What is the correct way of getting message UIDs via IMAPClient ?