Python Forum
No output for the code to read emails
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
No output for the code to read emails
#1
Hello,
I've tried the code given below to read emails using poplib but I'm unable to get the output.
import poplib
import string, random
import io, email

def readMail():
	server = 'pop.gmail.com'
	user = 'user_email'
	password = 'password'

	srv = poplib.POP3_SSL(server)
	srv.user(user)
	srv.pass_(password)

	for i in range(0,5):
		id, size = string.split(items[i])
		resp, text, octets = srv.retr(id)
		text = string.join(text,"\n")
		file = io.StringIO(text)
		message = email.Message(file)
		for k,v in message.items():
			print(k, "=", v)

readMail()
Reply


Messages In This Thread
No output for the code to read emails - by avani9659 - Aug-13-2018, 06:53 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  problem in output of a snippet code akbarza 2 457 Feb-28-2024, 07:15 PM
Last Post: deanhystad
  I cannot able to see output of this code ted 1 807 Feb-22-2023, 09:43 PM
Last Post: deanhystad
  Read All Emails from Outlook and add the word counts to a DataFrame sanaman_2000 0 1,939 Sep-15-2022, 07:32 AM
Last Post: sanaman_2000
  why I dont get any output from this code William369 2 1,191 Jun-23-2022, 09:18 PM
Last Post: William369
  Sending Emails on Autopilot Gyga_Hawk 3 1,777 Mar-15-2022, 08:20 AM
Last Post: Larz60+
  How can I organize my code according to output that I want ilknurg 1 1,225 Mar-11-2022, 09:24 AM
Last Post: perfringo
  Mark outlook emails as read using Python! shane88 2 6,746 Feb-24-2022, 11:19 PM
Last Post: Pedroski55
  Python code to read second line from CSV files and create a master CSV file sh1704 1 2,487 Feb-13-2022, 07:13 PM
Last Post: menator01
  Trying out the parsing/reading of emails from my outlook cubangt 0 6,358 Jan-12-2022, 08:59 PM
Last Post: cubangt
  How to read this code? Jlyk 3 1,757 Aug-19-2021, 06:10 AM
Last Post: Jlyk

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020