Python Forum
Python Automated Email
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python Automated Email
#8
Hey,

So just a quick one before we get started:
EMAIL_ADDRESS = "*********@gmail.com"
EMAIL_PASSWORD = "XXXX"
 
msg = EmailMessage()
msg['Subject'] = 'Email Subject'
msg['From'] = '"*********@gmail.com'
msg['To'] = sheet.cell_value(i, 3) # I replaced the 'To' email address here as I need the code to send email to the address from excel file msg.set_content("BODY OF EMAIL HERE")
 
with smtplib.SMTP_SSL('smtp.gmail.com', 465) as smtp:
    smtp.login(EMAIL_ADDRESS, EMAIL_PASSWORD)
    smtp.send_message(msg)
Is this ^ your exact code. Because as below:

EMAIL_ADDRESS = ""*********@gmail.com"
EMAIL_PASSWORD = "XXXX"
 
msg = EmailMessage()
msg['Subject'] = 'Email Subject'
msg['From'] = '"*********@gmail.com'
msg['To'] = sheet.cell_value(i, 3) # I replaced the 'To' email address here as I need the code to send email to the address from excel file 
msg.set_content("BODY OF EMAIL HERE")
 
with smtplib.SMTP_SSL('smtp.gmail.com', 465) as smtp:
    smtp.login(EMAIL_ADDRESS, EMAIL_PASSWORD)
    smtp.send_message(msg)
"msg.set_content("BODY OF EMAIL HERE")" needs to be on its own line. ^

Also: Comment out everything other than the email function to make sure the emailing works, then introduce the rest of the code and then we can go from there :-)

Regards,

Harley
Reply


Messages In This Thread
Python Automated Email - by aidanh26 - Jul-12-2020, 12:25 PM
RE: Python Automated Email - by HarleyQuin - Jul-12-2020, 01:17 PM
RE: Python Automated Email - by aidanh26 - Jul-12-2020, 01:21 PM
RE: Python Automated Email - by HarleyQuin - Jul-12-2020, 02:03 PM
RE: Python Automated Email - by aidanh26 - Jul-12-2020, 02:41 PM
RE: Python Automated Email - by HarleyQuin - Jul-12-2020, 03:48 PM
RE: Python Automated Email - by aidanh26 - Jul-12-2020, 04:14 PM
RE: Python Automated Email - by HarleyQuin - Jul-12-2020, 04:44 PM
RE: Python Automated Email - by aidanh26 - Jul-13-2020, 07:37 AM
RE: Python Automated Email - by HarleyQuin - Jul-13-2020, 09:00 AM
RE: Python Automated Email - by aidanh26 - Jul-13-2020, 04:09 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Help send email by Python using smtplib hangme 6 6,336 Jan-25-2020, 03:31 AM
Last Post: shapeg
  sending email with python shahpy 4 14,323 Oct-03-2016, 10:00 PM
Last Post: shahpy

Forum Jump:

User Panel Messages

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