Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating folders in outlook 2010 using python

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.

like image 904
lokheart Avatar asked Apr 14 '26 11:04

lokheart


1 Answers

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")
like image 138
lowitty Avatar answered Apr 16 '26 00:04

lowitty



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!