simple example of mimelib? and embedding (not attaching) images in email sent with python.

Jeff Shannon jeff at ccvcorp.com
Tue Aug 14 19:43:45 EDT 2001


Stephen wrote:

> I've looked through the archives regarding using smtplib and the
> numerous MIME related modules for sending email messages with attachments.
> I've found various solutions, some of which no longer seem to work, and
> was quite surprised how this seemingly banal task has caused so much trouble.
> However, in Microsoft Outlook, it's possible to embed image files into
> the actual message as opposed to having them attached.  This way, they
> display when the recipient views the message.  Just how does one compose
> a message like that with Python may I ask?

Of the top of my head, I'd guess that Outlook does this by using HTML messages
(content-type=text/html).  You can do this just as you would a plain text
message, except that you need to specify the proper content type, and of course
the message body must be valid html (at least, parseable by the recipients'
readers, some of which may have different opinions on what is "valid html").
Keep in mind that many people don't much care for receiving HTML mail, especially
thanks to Outlook's broken security regarding scripting...

It is true that the current Python std library, as I've seen it (I work with
2.0), doesn't have much high-level support for MIME and email.  I haven't looked
at the forthcoming Mimelib, yet, however, so I can't answer as to how well that
package addresses the current weaknesses.  I have, however, cobbled together a
usable "outbox" utility that allows me to easily send email, with MIME
attachments, based on text-file contents.  It's not all *that* difficult, really.

Jeff Shannon
Technician/Programmer
Credit International





More information about the Python-list mailing list