1 Replies - 361 Views - Last Post: 17 September 2019 - 04:48 AM Rate Topic: -----

#1 JavaSeeker   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 1
  • Joined: 03-February 19

Email messages from grouped email using IMAPClient

Posted 11 September 2019 - 10:39 PM

Hello,

I am trying to fetch email messages from a gmail inbox. So, there will be 1000s of messages sent to Inbox and since they are 1000s, the emails are grouped 100 per each email item.

When I tried this method, the program only fetches some but not all and especially it happens with grouped email messages. How can I get all the messages from that grouped email.

import email, time, sys
from imapclient import IMAPClient

with IMAPClient(HOST) as server:
server.login(USERNAME, PASSWORD)
server.select_folder('INBOX', readonly=True)

messages = server.search(['ALL', 'UNSEEN'])
for uid, message_data in server.fetch(messages, 'RFC822').items():
email_message = email.message_from_bytes(message_data[b'RFC822'])
print(email_message.get_payload(None, True))


The program should fetch all the email messages from the grouped email and output to the file (in my case I am grabbing the href links). How best I can achieve this ? Appreciate thoughts and suggestions.

Is This A Good Question/Topic? 1
  • +

Replies To: Email messages from grouped email using IMAPClient

#2 Choscura   User is offline

  • D.I.C Lover


Reputation: 478
  • View blog
  • Posts: 2,266
  • Joined: 18-October 08

Re: Email messages from grouped email using IMAPClient

Posted 17 September 2019 - 04:48 AM

So I think I've found the github account your code is copied from, have you tried running this? what has it done for you? If you're looking for somebody to write a program for you, possibly for your homework, then go the way of all the honest cheating students, and hire a freelance programmer.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1