Outlook/Exchange CDO/COM questions

John Taylor john_taylor_1973 at yahoo.com
Wed Jan 15 17:10:20 CET 2003


I have 3 questions about the code that I am writing (posted below).

1) This code works on Inbox, but I really need it to work on the "Sent
Items" folder, but can not figure this out.
2) Iterating through Recipients returns all names listed in the "To:"
header, how do I also get "CC:"?
3) Some of the text is unicode, but it is probably just a few
characters.  How do I print out unicode text, in the info() function. 
I imagine this is utf-16, since this is Microsoft.

Thanks,
John Taylor


from win32com.client import Dispatch

################################################################

def info(s,d):
	print
	print "=" * 60 , d
	print "%s" % s
	print "=" * 60 , d
	print
	print

################################################################

def msg_info(s):

	last = len(s.Inbox.Messages)
	curr = s.Inbox.Messages.Item(last)
	try:
		info(curr.Sender,"Sender")
		info(curr.Subject,"Subject",)
		info(curr.TimeSent,"Time Sent")
		info(curr.TimeReceived,"Time Received")
		info(curr.Sent,"Sent")
		info(curr.Submitted,"Submitted")
		info(curr.Recipients,"Recipients")
		info(curr.TimeCreated,"Time Created")
		info(curr.TimeLastModified,"Time Last Modified")
		#info(curr.Text,"Text")
	except AttributeError, e:
		print e

	print "=" * 75
	print

	a = curr.Recipients
	i = 1
	max = a.Count
	while i < max:
		b = a.Item(i).Name
		c = a.Item(i).AmbiguousNames
		d = a.Item(i).AddressEntry
		e = a.Item(i).Address
		print "%d) %s" % (i,b)
		print "%d) %s" % (i,c)
		print "%d) %s" % (i,d)
		print "%d) %s" % (i,e)
		print
		i = i+1

	print "=" * 75


################################################################

def main():
	s=Dispatch("Mapi.Session")
	s.Logon()
	msg_info(s)
	s.Logoff()

################################################################

main()




More information about the Python-list mailing list