msg.attach multiple attachments and passing vars to html
python at mrabarnett.plus.com
Wed Sep 1 02:44:10 CEST 2010
On 01/09/2010 00:24, aurfalien at gmail.com wrote:
> Few questions as I've been at this for dayz.
> Can I do multiple attachments in order via msg.attach as so;
> part1 = MIMEText(html, 'html')
> part2 = MIMEText(text, 'plain')
> part3 = MIMEText(html, 'html')
> I desire to attach part1, part2 and part3 in that order.
This might help:
> Also, is it somehow possible to pas python vars to html?
> My goal to to have an email that says something like;
> Welcome to ACME.
> A few LINKS to get you started.
> Your user name is USRNM and your password is PASS
> Where USRNM and PASS are python vars but the rest is an html based email.
> LINKS is an actual hyperlink, hence the desire to do html based emails.
Create a template HTML with placeholders and then the individual HTML
by replacing the placeholders with the values, something like:
template_html = "Your user name is %USRNM% and your password is
user_html = template_html.replace("%USRNM%",
That's the general idea.
More information about the Python-list