Yes I have already looked at the numerous posts showing how to do this however nothing has worked for me as of now which is why I'm asking.
The pictures above are what the email looks like in my inbox. I don;t have any others tabs (social, promotions etc) and this is the only email in my inbox. What I need to do is to get the link that you get redirected to when you click "Activate Account". So far this is what I have tried
import smtplib
import time
import imaplib
import email
ORG_EMAIL = "@gmail.com"
FROM_EMAIL = "eh + ORG_EMAIL
FROM_PWD = "eh"
SMTP_SERVER = "imap.gmail.com"
SMTP_PORT = 993
mail = imaplib.IMAP4_SSL(SMTP_SERVER)
mail.login(FROM_EMAIL,FROM_PWD)
mail.select('inbox')
type, data = mail.search(None, 'ALL')
mail_ids = data[0]
id_list = mail_ids.split()
first_email_id = int(id_list[0])
latest_email_id = int(id_list[-1])
for i in range(latest_email_id,first_email_id, -1):
typ, data = mail.fetch(str(i), '(RFC822)' )
for response_part in data:
if isinstance(response_part, tuple):
msg = email.message_from_string(response_part[1].decode())
email_subject = msg['subject']
email_from = msg['from']
b = email.message_from_string(response_part[1].decode())
print(msg.get_payload())
What this returns looks like this:
[<email.message.Message object at 0x000001A25ABEEFD0>, <email.message.Message object at 0x000001A25ABEEE80>]
Obviously this is not what the body looks like. So how can i get the body of the message and even if I do that will it include the link that redirects you to activate your account??
Comments
Post a Comment