[Tutor] Insert time into email

Chris “Kwpolska” Warrick kwpolska at gmail.com
Mon Oct 20 19:38:59 CEST 2014


Forwarding to list — please use Reply All… next time.

On Mon, Oct 20, 2014 at 6:28 PM, Crush <crushed26 at gmail.com> wrote:
> Where does the ."format(time=t,date=d)" go?
>
> I would assume something like
>
> msgTime = MIMEText()
> msgTime.add_header('not sure what to put here?' '<time>' .format(time=t))
> msgRoot.attach(msgTime)
>
> then in the actual html, something like...
> <table><tr><td>{time}</td></tr></table>?
>
> and yes, for simplicity sake, the date and time will be the same.

Do not bother with MIME for this.  It WON’T be simpler.  (it’s most
likely impossible, in fact.)

msgText = MIMEText('<table cellspacing="15" border="1">…rest of your
HTML here, complete with {time} and {date}
tags…</table>'.format(time=t, date=d), 'html')
msgAlternative.attach(msgText)

-- 
Chris “Kwpolska” Warrick <http://chriswarrick.com/>
PGP: 5EAAEA16
stop html mail | always bottom-post | only UTF-8 makes sense


More information about the Tutor mailing list