Hardware Reference
In-Depth Information
from time import gmtime, strftime
def get_latest_photo(files):
lt = operator.lt
if not files:
return None
now = time.time()
latest = files[0], now - os.path.getctime(files[0])
for f in files[1:]:
age = now - os.path.getctime(f)
if lt(age, latest[1]):
latest = f, age
return latest[0]
def emailphoto(msgtext, afilename):
#enter the e-mail account username between the quotes
smtp_user = “”
#enter the e-mail account password between the quotes
smtp_pass = “”
msg = MIMEMultipart()
#enter the target e-mail address between the quotes
msg['To'] = “”
#enter the e-mail account username between the quotes
msg['From'] = “”
#enter the message subject between the quotes
msg['Subject'] = “”
# That is what u see if don't have an e-mail reader:
msg.preamble = 'Multipart message.\n'
#sys.argv[1] is the 1st parameter that is passed to this
#and it contains the text for the body of the e-mail
part = MIMEText(msgtext)
msg.attach(part)
#The next 3 lines attach the photo using the filename
#passed in as the second parameter to this program
part = MIMEApplication(open(afilename,”rb”).read())
part.add_header('Content-Disposition', 'attachment',;
filename=afilename)
continued
Search WWH ::




Custom Search