[Python-Dev] Mail handeling with Python

Alex Martelli python-dev@python.org
Fri, 18 Jul 2003 11:59:09 +0200

On Friday 18 July 2003 11:44 am, Apurv Anand wrote:
> Hi,
> I am very new to Python.
> Need to know if I can achieve this with Python:
> ~ Read a mail from Outlook 2000 Clinet (or may be from Exchange server
> directly; but from the Client machine) ~ The mail will be filtered for

I have not done this myself, but there are plenty of Google hits that
suggest ways to proceed for this purpose.  For example, check out
http://www.boddie.org.uk/python/COM.html .

> certain words in subject / body (I want to read only one perticular mail I
> will recieve every week) ~ Find (make code guess) a string within the mail.
> (Basically its a UNC path that keeps changing according to the subfolders.
> The name of the machine is same so i have to write something which can
> guess (find) the UNC path within the mail (Its something like
> \\fileserver\foo\abc which can change to \\fileserver\foo\xyx) ~ Open this

I'm not sure how you'll go about "guessing" (which seems a very different
issue from _finding_) the string.  Anyway, once you have the mail in memory
you can apply both string searches and regular expressions.  If you code
a string literal, remember you need to double up backslashes (a syntax issue).

> UNC path and copy the contents to a local folder.

win32all (which you need to interface to Outlook) should also let you use
UNC paths, I believe.