ca**********@ukmail.com (Mark Carter) wrote:
Section 12.2.13 (from the email module) gives examples of how to send
attachments with emails. The problem is, it does not explain how to
send text in the body of the message. One line of code that is gives
is:
outer.preamble = 'You will not see this in a MIME-aware mail
reader.\n'
So how do I arrange it so that the text *will* be seen?
a snippet of my code, i've add the html as plain text as well. STrip the
html codes are you're done.
All this is email body work, nothing else.
This seems to work, even with Outlook (and others :] )
self.msgbody = "Date: " +time.strftime("%a, %d %b %Y %H:%M:%S
+0100", time.gmtime()) + '\r\n'
self.msgbody += "Subject: " +subject+ '\r\n'
self.msgbody += "From: " +self.fr+ '\r\n'
self.msgbody += "To: "+self.to + '\r\n'
self.msgbody += "Sender:
me@mydomain.com" + '\r\n'
self.msgbody += "Content-Type: multipart/alternative;
boundary=SEPERATORLINEWICHSHOULDNEVEROCCURINREALTE XT" + '\r\n'
self.msgbody += "MIME-Version: 1.0" + '\r\n\r\n'
self.msgbody += """
--SEPERATORLINEWICHSHOULDNEVEROCCURINREALTEXT
Content-Type: text/plain
%(textbody)s
--SEPERATORLINEWICHSHOULDNEVEROCCURINREALTEXT
Content-Type: text/html
<html>%(htmlbody)s</html>
--SEPERATORLINEWICHSHOULDNEVEROCCURINREALTEXT--
""" % {'textbody':body,'htmlbody':body}
gr.
Remco