Jul-13-2020, 04:09 PM
(Jul-13-2020, 09:00 AM)HarleyQuin Wrote: Then pass it to the email program because your code seems fine to be honest.
So I currently have it like this:
[python]
for i in range(sheet.nrows):
if sheet.cell_value(i, 0) == scannedNumberPlateNumber:
print('Found in column A - ignore')
if sheet.cell_value(i, 2) == scannedNumberPlateNumber:
print('Found in column C - send email to ' + sheet.cell_value(i, 3) )
EMAIL_ADDRESS = "[email protected]"
EMAIL_PASSWORD = "XXXX"
some_variable = str(sheet.cell_value(i, 3))
msg = EmailMessage()
msg['Subject'] = 'Email Subject'
msg['From'] = '[email protected]'
msg['To'] = some_variable
msg.set_content('Please move car')
with smtplib.SMTP_SSL('smtp.gmail.com', 465) as smtp:
smtp.login(EMAIL_ADDRESS, EMAIL_PASSWORD)
smtp.send_message(msg)
[python]
But it returns the error: NameError: name 'some_variable' not defined
But if I change
[python]
msg['To'] = some_variable
[python]
to my own email address it will successfully send the email. I just can't get it to send the email to (sheet.cell_value(i, 3)) :(