Created
December 5, 2013 18:24
-
-
Save douglasgoodwin/7810592 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import imaplib | |
import csv | |
from email import message_from_string | |
import time | |
srv = imaplib.IMAP4_SSL("imap.gmail.com") | |
srv.login('[email protected]', 'joepw') | |
srv.select('[Gmail]/Drafts') | |
def send_m(first_name, last_name, emailaddr, attendance, grade): | |
message = message_from_string("""To: "%s %s" <%s> | |
Subject: [CSSM231] Your Grade | |
Hello %s, | |
This email contains your current score for CSSM231 "All That Glitters". | |
attendance: %s (should be 70 or higher to pass) | |
grade: %s | |
The grade gets translated into HP/P/LP according to the following scale: | |
85+ HP | |
75-84 P | |
60-74 LP | |
Please contact me if you have any questions. | |
-Thanks, | |
-Doug | |
""" % (first_name, last_name, emailaddr, first_name, attendance, grade)) | |
srv.append("[Gmail]/Drafts", | |
'', | |
imaplib.Time2Internaldate(time.time()), | |
str(message)) | |
ifile = open('scores.csv', "rb") | |
csvreader = csv.reader(ifile) | |
for row in csvreader: | |
"""first_name,last_name,email,grade,attendance""" | |
first_name = row[0] | |
last_name = row[1] | |
emailaddr = row[2] | |
attendance = row[3] | |
grade = row[4] | |
print first_name, last_name, emailaddr, first_name, attendance, grade | |
send_m(first_name, last_name, emailaddr, attendance, grade) | |
time.sleep(1) | |
""" | |
scores.csv like this: | |
first_name,last_name,email,attendance,grade | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
first_name | last_name | attendance | grade | ||
---|---|---|---|---|---|
fonz | shark | [email protected] | 77 | 88 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment