If Exchange Server is your mail server, and have Outlook client,
try to use "Outlook.Application" instead of CDO, "MailItem" has 
"SentOn" or "ReceivedTime" property.

-----Original Message-----
From: Ganz, Will [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, August 28, 2002 5:42 PM
To: [EMAIL PROTECTED]
Subject: Using CDO to handle messages in Outlook


Environment:
Windows XP
Dell 4400, 128megs RAM, internal video
ActivePython 2.1.212

Problem:
The company has an automated process(a Perl script) that generates numerous
email messages(300+ each AM) to report the status of file downloads. The
Perl script while using SMTP does _not_ generate the 'Sent' field for the
message header. The Perl script is cast in political cement and is
immutable. Rule Wizard is used in Outlook 2002 to sort/triage the messages
to different folders for each facility or type of problem encountered.
Desired goal is to be able to programmatically read through all these emails
to generate a consolidated report. 

Using the example from pages 278-281 of 'Python Programming on Win32', have
been able to loop through all of the messages in a given folder. The message
body, sender, and subject line are all easily accessible. Tried various
resources and the web site mentioned on page 281 to find the message
attribute that would give me the date/time that a file was received without
success. 

This is a snippet of what I've gotten working so far:

from win32com.client import Dispatch

s=Dispatch("Mapi.Session")
s.Logon()

messages =
s.Inbox.Folders("Production").Folders("RegionI").Folders("test").Messages

msg = messages.GetFirst()
while msg is not None:
    if msg.Subject == "test02":
        print msg.Sent
        print "got message", msg.Sender.Name, msg.Subject, msg.Text
    msg = messages.GetNext()


Interestingly enough, that 'print msg.Sent' will cause the character '1' to
be printed to the screen. This could be due that the message had been sent
and that attribute would be true.

Desired Goal:
Access the date/time that a message was received so that an 'if' statement
could be written to select only those messages for the current date. Such
as:

    if msg.Date == currentDate:
        do processing here<


Any help would be appreciated.

Thanks,


Will
_______________________________________________
ActivePython mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Other options: http://listserv.ActiveState.com/mailman/listinfo/ActivePython
_______________________________________________
ActivePython mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Other options: http://listserv.ActiveState.com/mailman/listinfo/ActivePython

Reply via email to