I am trying to read a specific email from my mailbox. And I want to click on 'Click here' hyperlink to start downloading the excel file on my laptop. I am trying below code:
import smtplib
import time
import imaplib
import email
import traceback 
ORG_EMAIL   = "@gmail.com"
FROM_EMAIL  = "myemail" + ORG_EMAIL
FROM_PWD    = "password"
SMTP_SERVER = "imap.gmail.com"
SMTP_PORT   = 993
def read_email_from_gmail():
    try:
        mail = imaplib.IMAP4_SSL(SMTP_SERVER)
        mail.login(FROM_EMAIL,FROM_PWD)
        mail.select('inbox')
        data = mail.search(None, 'ALL')
        mail_ids = data[1]
        id_list = mail_ids[0].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):
            data = mail.fetch(str(i), '(RFC822)' )
            for response_part in data:
                arr = response_part[0]
                if isinstance(arr, tuple):
                    msg = email.message_from_string(str(arr[1],'unicode_escape'))
                    email_subject = msg['somesubject']
                    email_from = msg['igotemailfrom@something.com']
                    # print('From : ' + email_from + '\n')
                    # print('Subject : ' + email_subject + '\n')
    except Exception as e:
        traceback.print_exc() 
        print(str(e))
read_email_from_gmail()Can someone please help on how can I just click on the link 'Click here to download data' from email I am fetching?
 
     
     
    