[Tutor] Insert time into email

Albert-Jan Roskam fomcl at yahoo.com
Wed Oct 22 21:35:23 CEST 2014


----------------------------
On Mon, Oct 20, 2014 6:02 PM CEST Chris “Kwpolska” Warrick wrote:

>On Mon, Oct 20, 2014 at 2:34 PM, Bo Morris <crushed26 at gmail.com> wrote:
>> hello all, hope everyone is doing well.
>>
>> 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.
>>
>> #!/usr/bin/python
>>
>> import smtplib
>> from email.MIMEMultipart import MIMEMultipart
>> from email.MIMEText import MIMEText
>> from email.MIMEImage import MIMEImage
>> import time
>>
>> strFrom = "HourlyReport.com"
>
>PS. You may want to use a real e-mail address here.  Or, at the very
>least, something that looks like one.
>
>> #strTo = "engineering at oneconnxt.com"
>> #strTo = "mmedley at onemediacorpinc.com"
>> strTo = "bo at onemediacorpinc.com"
>>
>> 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']
>>
>> t = time.strftime("%H:%M:%S")
>> d = time.strftime("%d/%m/%Y")
>>
>> msgRoot = MIMEMultipart('related')
>> msgRoot['Subject'] = 'Test Hourly Report'
>> msgRoot['From'] = strFrom
>> msgRoot['To'] = strTo
>> msgRoot.preamble = 'This is a multi-part message in MIME format.'
>>

Shouldn't date be specified too? msgRoot['Date'] = datetime...
The other day I forgot to do this and the date was Jan 1970 iirc (Linux, I have never seen it on Windows)


More information about the Tutor mailing list