Using Python 2.7 on Windows 7 Platform.
I am trying to send email based on ID.
I currently have ID: Email set up in a dictionary to pull from. However some ID's have multiple emails associated. How would I set that up to send an email to each recipient. I've tried [ID]:[email, email], and it seems to only send to the first email address listed. Thanks in advance.
Dictionary creation code below.
COLS = ['rep_id', 'email', 'password']
with open('commissionrepemaillist.csv', 'r') as infile:
email_dict = {
row[0]: dict(zip(COLS, row)) for row in csv.reader(infile)
}
And I'm using that to assign the variable I use to send the email
email = email_dict[ID]['email']
Hard to answer with only the info given so far, but it looks like d[ID]=[email1, email2, etc]
where d
is your dictionary. d[ID]
is a list of emails corresponding to ID
. If you want to send email to a list of email addresses, this question is a good one to look at: Send Email to multiple recipients from .txt file with Python smtplib
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments