Question

I know how to get the name of folders in outlook 2010 using the code below:

import win32com.client

ol = win32com.client.Dispatch("Outlook.Application")
ns = ol.GetNamespace("MAPI")
inbox = ns.Folders(6).Folders(2)

How can I add a folder in Folder(2)? I tried the Folders.Add Method method as mentioned in http://support.microsoft.com/kb/208520 but fail.

Was it helpful?

Solution

I think you have made a small mistake, the Add function is the function of Folders. Not a certain Folder like Folders(2)

You can try the code below and it should work:

import win32com.client

ol = win32com.client.Dispatch("Outlook.Application")
ns = ol.GetNamespace("MAPI")
inbox = ns.Folders(6).Folders(2)
inbox.Folders.Add("My Folder Src")
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top