Cannot get email package to work

Jeff Blaine cjblaine at gmail.com
Sun Sep 19 10:39:27 EDT 2004


I figured it out after trying again (and it worked).  I believe I had
done the following in my interpreter:

 >>> import email
 >>> myfd = open('c:/temp/my-work.eml')
 >>> email.message_from_file(myfd)
<email.Message.Message instance at 0x00A799E0>     <-- oops, forgot to assign
 >>> msg = email.message_from_file(myfd)            <-- now this is broken
 >>> msg.keys()
[]
 >>> msg.get_all('From')
 >>>

It works though if you do it right the first time.  Thanks for the prodding.

 >>> newfd = open("C:/temp/my-work.eml", 'r')
 >>> newmsg = email.message_from_file(newfd)
 >>> newmsg.keys()
['Return-Path', 'Delivered-To', 'Received', 'Received', 'Received', 
'Message-ID', 'Date', 'From', 'User-Agent', 'X-Accept-Language', 
'MIME-Version', 'To', 'Subject', 'Content-Type', 'Content-Transfer-Encoding']
 >>>


Heiko Wundram wrote:

> Am Sonntag, 19. September 2004 00:12 schrieb Steve Holden:
> 
>>Under Windows Python 2.3.3 (#51, Dec 18 2003, 20:22:39), however, I see
>>
>> >>> fd=file("C:\\cygwin\\tmp\\test.eml")
>> >>> msg =- email.message_from_file(fd)
>>
>>Traceback (most recent call last):
>>   File "<stdin>", line 1, in ?
>>AttributeError: Message instance has no attribute '__neg__'
> 
> 
> ---> Typo, should be msg = email.message_from_file(fd)
> 
> So, I guess it does work under windows. ;)
> 
> Heiko.



More information about the Python-list mailing list