472,358 Members | 1,915 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,358 software developers and data experts.

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 2018

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Tuang | last post by:
I've been looking all over in the docs, but I can't figure out how you're *supposed* to parse formatted strings into numbers (and other data types, for that matter) in Python. In C#, you can say...
0
by: Naren | last post by:
I have an XML like the one below. I am using SAX parsing and I need to get the information between the tags of the Email element. First i try to access the content and print it out and it gives...
3
by: Girish | last post by:
Hi All, I have written a component(ATL COM) that wraps Xerces C++ parser. I am firing necessary events for each of the notifications that I have handled for the Content and Error handler. The...
16
by: Terry | last post by:
Hi, This is a newbie's question. I want to preload 4 images and only when all 4 images has been loaded into browser's cache, I want to start a slideshow() function. If images are not completed...
23
by: Hostile17 | last post by:
I keep coming across people, online and in real life, who believe that to code single tags like <br> and <img> with trailing slashes, <br /> and <img /> is considered "best practice" and when...
3
by: uestebanez | last post by:
Hi everybody! I have a little problem working with libxml SAX API. The problem is that I don't know how to stop parsing when I have processed the data I need. I don't want to parse all file, I...
10
by: Bryce Calhoun | last post by:
Hello, First of all, this is a .NET 1.1 component I'm creating. SUMMARY ----------------------- This component that I'm creating is, for all intents and purposes, a document parser (I'm...
33
by: Kent Feiler | last post by:
I forgot to close a <span>. The html was: <span class="something">aaaaaa bbbbbbbb ccccccccccccc <p> sssss ttttttt </p> etc </body>
12
by: Julian | last post by:
Hi, I am having problems with a function that I have been using in my program to read sentences from a 'command file' and parse them into commands. the surprising thing is that the program works...
13
by: Phillip B Oldham | last post by:
Is there a standard library for parsing emails that can cope with the different way email clients quote?
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
1
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. header("Location:".$urlback); Is this the right layout the...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.