473,394 Members | 1,840 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 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 2111

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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.