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()
[]
? 3 1868
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@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 <cj******@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
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.
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. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Roman Suzi |
last post by:
(this is a repost with an addition - probably noone noticed my message first
time)
Hi!
Just to be sure, is email package of Python 2.3 thread-safe or not
(to use, for example, in...
|
by: Bill Murray |
last post by:
I am using VS.NET 2003 and trying to deploy a service program(c++) to a Windows 2000 Server system. I have also written a small DLL (USSsetup.dll) that is used to start/stop the service using a...
|
by: PHLICS_Admin |
last post by:
Hi All,
There are two network cards in one computer (named A) , and there is one
network card in another computer(named B).
On computer A: one network card is used to connect to internet, and...
|
by: Peter |
last post by:
Hi
I have this situation where I had all my ASP.NET application working fine until I installed one particular ASP.NET application the other day. Now, one of my applications raises this error...
|
by: Michael |
last post by:
Hi,
I'm trying to do something which should be very simple - connect to the
MySQL database. Here is the call, followed by the error msg.
$conn = mysql_connect("localhost", "root", "");
...
|
by: Anthony Smith |
last post by:
I always get this message. No matter what package
$ pear install Date
PHP Warning: Module 'oci8' already loaded in Unknown on line 0
No releases available for package "pear.php.net/Date"...
|
by: Alan Isaac |
last post by:
This is really a repackaging of an earlier question,
probably illustrating that I still do not understand relative imports.
Suppose I have the package structure (taken from the example at...
|
by: blazedaces |
last post by:
Hello, it's been a while since I posted on these forums. My issue I think isn't as much in my code as it's in the syntax and structure in references other packages. I'll get straight to it then:
...
|
by: Erik Witkop |
last post by:
So I have been trying to get this to work all day. I can't get a local
file on my web server to attach to an email. Right now I have it
printing out in the body of the email. Please help me with...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |