Open eduardolc21 opened 3 years ago
Yea, what is wrong with that?
I was trying with the code below, but It is not working. PS. I am new to python. Thanks for your answer.
yag = yagmail.SMTP('xxxx@gmail.com', 'mypass')
with open("hoja2.csv","r") as csvfile: csv_reader = csv.reader(csvfile) next(csv_reader)
for line in csv_reader:
for name, email, message in tuple(line.strip().split(',') for line in csvfile):
yag.send(email, subject = name, contents = message)
It looks like it should just work. Only the yagmail import seems to miss. What's the error you get?
#Thanks for your answer and comments import yagmail import csv sender_email = "xxxx@gmail.com" subject = "Take a look" sender_password = input(f"Please enter the password {sender_email}:\n") yag = yagmail.SMTP(user = sender_email, password = sender_password) contents = ["This is your first paragraph in our email", "As you can see" ] with open("contacts_file.csv") as csvfile: csv_reader = csv.reader(csvfile) next(csv_reader)
for line in csv_reader:
for name, email, grade in line.strip().split(','):
yag.send(email, subject = name, contents = contents)
AttributeError Traceback (most recent call last)
AttributeError: 'list' object has no attribute 'strip'
In your case it means line is a list and not a string.