469,938 Members | 2,462 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,938 developers. It's quick & easy.

RE: help with parsing email

Thanks everyone who tried to help me to parse incoming email from an exchange server:

Now, I am getting following error; I am not sure where I am doing wrong. I appreciate any help how to resolve this error and extract emails from an exchange server.
First I tried:
>>mailserver = 'EXCHVS01.my.org'
mailuser = 'myname'
mailpasswd = 'mypass'
mailserver = poplib.POP3(mailserver)
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
File "C:\Python24\lib\poplib.py", line 96, in __init__
raise socket.error, msg
error: (10061, 'Connection refused')

The other way:
>>mailserver = 'pop.EXCHVS01.ad.my.org'
mailuser = 'm*****@my.org'
mailpasswd = 'mypass'
mailserver = poplib.POP3(mailserver)
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
File "C:\Python24\lib\poplib.py", line 84, in __init__
for res in socket.getaddrinfo(self.host, self.port, 0, socket.SOCK_STREAM):
gaierror: (11001, 'getaddrinfo failed')
I tried above ways but getting error

Thanks
sk

-----Original Message-----
From: py***********************************@python.org [mailto:py***********************************@pytho n.org] On Behalf Of Gabriel Genellina
Sent: Monday, August 18, 2008 6:43 AM
To: py*********@python.org
Cc: py**********@python.org
Subject: Re: help with parsing email

En Thu, 14 Aug 2008 12:50:57 -0300, Ahmed, Shakir <sh*****@sfwmd.govescribió:
I need to grab/parse numeric numbers such as app number from incoming
emails stored in Microsoft Outlook (Microsoft Exchange server) with
specified subject line.

The email body is like this

myregion ; tst ; 11-Aug-2008

http://my.xyz.com/dddd/content/ifs/a...est_337683.pdf

I need to extract 080612-21_ number from above line from incoming
emails.
Help from Maric Michaud [ma***@aristote.info]

Three options here :

- dealing directly with outlook mailboxes files, I used some open source code
to parse .pst files in past, but you'll need some googling to match your
requirements. Doesn't help if there is an instance of outlook running on the
box.

- use the outlook COM or even some windows MAPI interface via WIN32 API
(pywin32), can't help with this one.

- access emails directly on the Exchange server via standard python modules
poplib or imaplib, my preferred choice if one of these protocols are
supported by your environment. You won't need no extensions, just a standard
python installation, and your code will work with most mail delivery agent
and will run on all python supported platform.
==========================
Help from Gabriel Genellina

I can't help with the part dealing with Outlook - but once you retrieved the email body, it's easy:

import re
re_number = re.compile(r"NoticeOfapplication/([0-9-_]+)")
match = re_number.search(body)
if match:
print match.group(1)

(this matches any numbers plus "-" and "_" after the words NoticeOfapplication written exactly that way)

--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list

Aug 18 '08 #1
0 1864

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Tuang | last post: by
3 posts views Thread by Girish | last post: by
16 posts views Thread by Terry | last post: by
3 posts views Thread by uestebanez | last post: by
33 posts views Thread by Kent Feiler | last post: by
12 posts views Thread by Julian | last post: by
13 posts views Thread by Phillip B Oldham | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.