When I tried it: folders = outlook.GetRootFolder() I got the following error message: AttributeError: object has no attribute 'GetRootFolder
FYI, when I do: print dir(outlook) that method doesn't show up: ['AddStore', 'AddStoreEx', 'CLSID', 'CompareEntryIDs', 'CreateContactCard', 'CreateRecipient', 'CreateSharingItem', 'Dial', 'GetAddressEntryFromID', 'GetDefaultFolder', 'GetFolderFromID', 'GetGlobalAddressList', 'GetItemFromID', 'GetRecipientFromID', 'GetSelectNamesDialog', 'GetSharedDefaultFolder', 'GetStoreFromID', 'Logoff', 'Logon', 'OpenSharedFolder', 'OpenSharedItem', 'PickFolder', 'RefreshRemoteHeaders', 'RemoveStore', 'SendAndReceive', '_ApplyTypes_', '__cmp__', '__doc__', '__getattr__', '__init__', '__module__', '__repr__', '__setattr__', '_get_good_object_', '_get_good_single_object_', '_oleobj_', '_prop_map_get_', '_prop_map_put_', 'coclass_clsid'] dir doesn't always pick everything up, but just in case it's useful... Full code below: ---------------------------------- import win32com.client # Connect to Outlook, which has to be running try: print "trying to open up Outlook..." outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI") except: print "Could not open Outlook" print "successfully connected to Outlook\n" # Count the number of messages in the inbox inbox = outlook.GetDefaultFolder(win32com.client.constants.olFolderInbox) messages = inbox.Items print "number of messages in inbox:", messages.Count # Count the number of tasks in the task list task_list = outlook.GetDefaultFolder(win32com.client.constants.olFolderTasks) tasks = task_list.Items print "number of tasks in the task list:", tasks.Count folders = outlook.GetRootFolder() ---------------------------------- Thanks, Anders On Wed, Aug 24, 2011 at 6:37 PM, Tim Roberts <t...@probo.com> wrote: > Anders Schneiderman wrote: > > > > I'm trying to read messages that are in folders in Outlook 2010, and > > I'm running into trouble. Between looking at other folk's code and > > trying to make sense out of the Microsoft Object Model documentation, > > I've been able to figure out how to read items in the inbox and other > > things in default folders, such as tasks: by using GetDefaultFolder. > > > > I think you want outlook.GetRootFolder(), then enumerate the Folders > collection within that. > > http://msdn.microsoft.com/en-us/library/ff860733.aspx > > -- > Tim Roberts, t...@probo.com > Providenza & Boekelheide, Inc. > >
_______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32