I asked a question earlier about trying  to send an outlook message as
an attachment, but didn't get a response.  I'm so confused ... so I'm
going to see if I can some up with a simpler question.

I've have a file called 'foo.mht' that begins like this:

Content-Type: message/rfc822
Content-Transfer-Encoding: 7bit
x-mimeole: Produced By Microsoft Exchange V6.5
Content-class: urn:content-classes:message
MIME-Version: 1.0
Content-Type: multipart/alternative;
        boundary="----_=_NextPart_003_01CA61C6.4B387F54"
... lines removed ...
This is a multi-part message in MIME format.

The code I use to create the file is functionally equivalent to this:

   mailString = sys.stdin.read()                                  #
read mail message from stdin
   message = email.message_fom_string(string)         # turn it into a
message

   # find a node in the message that is rfc822, and save it to a file
as a string
   for part in message.walk():
      if part.get_content_type() == "message/rfc822":
          f = open("foo.mht", "w")
          print >>f, part.as_string()
          f.close()

I am hazy on this email stuff, but I think that the foo.mht file
represents an on-file version of an email that I should be able to now
send out as an attachment.

I think I should be able to do something like this:

msg = EmailMultiAlternatives(subject, body, from, to)
msg.attach_file("foo.mht")
msg.send()

But when send() is called, I get the error:

*** TypeError: Expected list, got <type 'str'>

If I attach a gif or png my code works ok, so I've got the basics
down, but I know I'm doing something wrong with this rfc822 type of
attachment.

I guess I need to somehow turn foo.mht back into a message prior to
attaching it?  Could anyone give me pointer?   I've been reading
through the doc, but this mail encoding stuff is still black magic to
me and I can't find much in the way of example code.

Margie



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to