Cannot get email package to work

Steve Holden steve at holdenweb.com
Sun Sep 19 00:12:18 CEST 2004


Jeff Blaine wrote:

> Python 2.3.4 for Windows
> 
> Just trying a simple test today.  I clicked on an email message in Mozilla
> 1.7.3's mail reader.  I selected 'Save As' and saved it as the default 
> type.
> I opened the file with Wordpad to examine it, and sure enough it looks like
> a complete email message with headers, newline, and body.
> 
>     >>> import email
>     >>> myfd = open('c:/temp/my-work.eml')
>     >>> msg = email.message_from_file(myfd)
>     >>> msg
>     <email.Message.Message instance at 0x00A70E18>
>     >>> msg.get_all('From')
>     >>> print msg
>     From nobody Fri Sep 17 17:26:06 2004
> 
> 
>     >>> msg.keys()
>     []
> 
> ?
Very strange. I stored your message in the way you described and I see 
the following (under Cygwin):

sholden at DELLBOY ~
$ python
Python 2.3.4 (#1, Jun 13 2004, 11:21:03)
[GCC 3.3.1 (cygming special)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
 >>> import email
 >>> myfd = open("/tmp/test.eml")
 >>> msg = email.message_from_file(myfd)
 >>> msg
<email.Message.Message instance at 0xa0cc48c>
 >>> msg.get_all("From")
['Jeff Blaine <cjblaine at gmail.com>']
 >>> msg.keys()
['Path', 'From', 'User-Agent', 'X-Accept-Language', 'MIME-Version', 
'Newsgroups'
, 'Subject', 'Content-Type', 'Content-Transfer-Encoding', 'Lines', 
'Message-ID',
  'NNTP-Posting-Host', 'X-Complaints-To', 'X-Trace', 
'NNTP-Posting-Date', 'Organi
zation', 'Date', 'Xref', 'X-Received-Date']
 >>>

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__'

which I am somewhat unable to explain.

so-now-you-have-two-problems-ly y'rs  - steve





More information about the Python-list mailing list