Hello all,

I'm trying to script email from database data. Following the examples at 
http://docs.python.org/3.3/library/email-examples.html I'm able to send simple 
emails, multipart emails with attachments, and multipart emails with 
alternative text. What I'm trying to do now is get multipart emails with 
alternative text, that also have attachment(s). In order to do so, as I 
understand it I need to have two unique boundaries - one to begin the post, and 
separate the message from the attachment(s), and another nested within the 
message body, to separate the alternative text versions. Using a single unique 
separator displays only the attachment, without the message text.

What I need to end up with is something like this:

Content-Type: multipart/mixed; boundary="===============4658086012177675674=="
MIME-Version: 1.0
Subject: Subject
From: Me
To: You

--===============4658086012177675674==
Content-Type: multipart/alternative; 
boundary="===============411111111111175674=="
#THIS IS THE NESTED SEPARATOR WITH 'ALTERNATIVE' TYPE

--=============== 411111111111175674==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

Simple Text Message
--=============== 411111111111175674 ==
Content-Type: text/html; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

<html>Fancy Text Message</html>
--=============== 411111111111175674 ==
--===============4658086012177675674==
Content-Type: text/html; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="123File.HTML"

THE ATTACHED FILE
--===============4658086012177675674==--

Building this by hand displays properly. If there's a simple way to do this 
with the tools provided in v3.3 I would love to learn about it. I think I could 
build the extra headers and separator into my text files, but I would like to 
learn a Python solution(s).

Thanks!

M
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to