<div dir="ltr">hello all, hope everyone is doing well. <div><br></div><div>The below code works, however I am going back and trying to enter the time and date and I cant quite figure out how to do this without breaking the code. </div><div><br></div><div><div>#!/usr/bin/python</div><div><br></div><div>import smtplib</div><div>from email.MIMEMultipart import MIMEMultipart</div><div>from email.MIMEText import MIMEText</div><div>from email.MIMEImage import MIMEImage</div><div>import time</div><div><br></div><div>strFrom = "HourlyReport.com"</div><div><br></div><div>#strTo = "<a href="mailto:engineering@oneconnxt.com">engineering@oneconnxt.com</a>"</div><div>#strTo = "<a href="mailto:mmedley@onemediacorpinc.com">mmedley@onemediacorpinc.com</a>"</div><div>strTo = "<a href="mailto:bo@onemediacorpinc.com">bo@onemediacorpinc.com</a>"</div><div><br></div><div>l = ['3102EHD-01108.png', '3102DHD-01109.png','3102EHD-01082.png', '3102DHD-01033.png', '3102EHD-01302.png', '3102DHD-01149.png', '3102EHD-01125.png', '3102DHD-01144.png', '3102EHD-01105.png'] </div><div><br></div><div>t = time.strftime("%H:%M:%S")</div><div>d = time.strftime("%d/%m/%Y")</div><div><br></div><div>msgRoot = MIMEMultipart('related')</div><div>msgRoot['Subject'] = 'Test Hourly Report'</div><div>msgRoot['From'] = strFrom</div><div>msgRoot['To'] = strTo</div><div>msgRoot.preamble = 'This is a multi-part message in MIME format.'</div><div><br></div><div>msgAlternative = MIMEMultipart('alternative')</div><div>msgRoot.attach(msgAlternative)</div><div><br></div><div>msgText = MIMEText('This is the alternative plain text message.')</div><div>msgAlternative.attach(msgText)</div><div><br></div><div>msgText = MIMEText('<table cellspacing="15" border="1"><tr><td><img src="cid:3102EHD-01108.png" width="400" height="300"></img><table><tr><td>TIME<td><td>DATE</td></td></tr></table></td><td><img src="cid:3102DHD-01109.png" width="400" height="300"></img><table><tr><td>TIME<td><td>DATE</td></td></tr></table></td></tr><table cellspacing="15" border="1"><tr><td><img src="cid:3102EHD-01082.png" width="400" height="300"></img><table><tr><td>TIME</td><td>DATE</td></tr></table></td><td><img src="cid:3102DHD-01033.png" width="400" height="300"></img><table><tr><td>TIME</td><td>DATE</td></tr></table></td></tr></table><table cellspacing="15" border="1"><tr><td><img src="cid:3102EHD-01302.png" width="400" height="300"></img><table><tr><td>TIME</td><td>DATE</td></tr></table></td><td><img src="cid:3102DHD-01149.png" width="400" height="300"></img><table><tr><td>TIME</td><td>DATE</td></tr></table></td></tr><table cellspacing="15" border="1"><tr><td><img src="cid:3102EHD-01125.png" width="400" height="300"></img><table><tr><td>TIME</td><td>DATE</td></tr></table></td><td><img src="cid:3102DHD-01144.png" width="400" height="300"></img><table><tr><td>TIME</td><td>DATE</td></tr></table></td></tr></td></tr></table><table cellspacing="15" border="1"><tr><td><img src="cid:3102DHD-01144.png" width="400" height="300"></img><table><tr><td>TIME</td><td>DATE</td></tr></table></td></tr></table>', 'html')</div><div>msgAlternative.attach(msgText)</div><div><br></div><div>for image in l:</div><div>    with open(image, 'rb') as fh:</div><div>        msgImage = MIMEImage(fh.read())</div><div>        msgImage.add_header('Content-ID', '<{0}>'.format(image))</div><div>        msgRoot.attach(msgImage)</div><div>        </div><div><br></div><div>try:</div><div>   smtpObj = smtplib.SMTP('localhost')</div><div>   smtpObj.sendmail(strFrom, strTo, msgRoot.as_string())         </div><div>   print "Successfully sent email"</div><div>except smtplib.SMTPException:</div><div>   print "Error: unable to send email"</div></div><div><br></div><div>I need to enter the time and date in the html where "TIME" and "DATE" are. I imagine I can do this by adding "cid: t" and "cid:d" which just refers back to t = "time.strftime("%H:%M:%S")" "d = time.strftime("%d/%m/%Y")"?</div><div><br></div><div>Thanks in advance for any help. </div><div> <br></div></div>