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:
Traceback (most recent call last):
File "<interacti ve input>", line 1, in ?
File "C:\Python24\li b\poplib.py", line 96, in __init__
raise socket.error, msg
error: (10061, 'Connection refused')
The other way:
Traceback (most recent call last):
File "<interacti ve input>", line 1, in ?
File "C:\Python24\li b\poplib.py", line 84, in __init__
for res in socket.getaddri nfo(self.host, self.port, 0, socket.SOCK_STR EAM):
gaierror: (11001, 'getaddrinfo failed')
I tried above ways but getting error
Thanks
sk
-----Original Message-----
From: python-list-bounces+shahmed =sfwmd.gov@pyth on.org [mailto:python-list-bounces+shahmed =sfwmd.gov@pyth on.org] On Behalf Of Gabriel Genellina
Sent: Monday, August 18, 2008 6:43 AM
To: python-list@python.org
Cc: python-win32@python.or g
Subject: Re: help with parsing email
En Thu, 14 Aug 2008 12:50:57 -0300, Ahmed, Shakir <shahmed@sfwmd. govescribió:
Help from Maric Michaud [maric@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"No ticeOfapplicati on/([0-9-_]+)")
match = re_number.searc h(body)
if match:
print match.group(1)
(this matches any numbers plus "-" and "_" after the words NoticeOfapplica tion written exactly that way)
--
Gabriel Genellina
--
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.or g'
>>mailuser = 'myname'
>>mailpasswd = 'mypass'
>>mailserver = poplib.POP3(mai lserver)
>>mailuser = 'myname'
>>mailpasswd = 'mypass'
>>mailserver = poplib.POP3(mai lserver)
File "<interacti ve input>", line 1, in ?
File "C:\Python24\li b\poplib.py", line 96, in __init__
raise socket.error, msg
error: (10061, 'Connection refused')
The other way:
>>mailserver = 'pop.EXCHVS01.a d.my.org'
>>mailuser = 'myname@my.org'
>>mailpasswd = 'mypass'
>>mailserver = poplib.POP3(mai lserver)
>>mailuser = 'myname@my.org'
>>mailpasswd = 'mypass'
>>mailserver = poplib.POP3(mai lserver)
File "<interacti ve input>", line 1, in ?
File "C:\Python24\li b\poplib.py", line 84, in __init__
for res in socket.getaddri nfo(self.host, self.port, 0, socket.SOCK_STR EAM):
gaierror: (11001, 'getaddrinfo failed')
I tried above ways but getting error
Thanks
sk
-----Original Message-----
From: python-list-bounces+shahmed =sfwmd.gov@pyth on.org [mailto:python-list-bounces+shahmed =sfwmd.gov@pyth on.org] On Behalf Of Gabriel Genellina
Sent: Monday, August 18, 2008 6:43 AM
To: python-list@python.org
Cc: python-win32@python.or g
Subject: Re: help with parsing email
En Thu, 14 Aug 2008 12:50:57 -0300, Ahmed, Shakir <shahmed@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
>
>
I need to extract 080612-21_ number from above line from incoming
emails.
emails stored in Microsoft Outlook (Microsoft Exchange server) with
specified subject line.
>
The email body is like this
>
myregion ; tst ; 11-Aug-2008
>
>
I need to extract 080612-21_ number from above line from incoming
emails.
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"No ticeOfapplicati on/([0-9-_]+)")
match = re_number.searc h(body)
if match:
print match.group(1)
(this matches any numbers plus "-" and "_" after the words NoticeOfapplica tion written exactly that way)
--
Gabriel Genellina
--