D-man Posted September 4, 2015 Share Posted September 4, 2015 Hi,I am able to add folders and sub folders to my default data file in Outlook using the code below. I also have a second data file (PST) loaded in Outlook. How do I add a sub folder to that location?Global $oOutlook = _OL_Open()Global $oFolder = _OL_FolderCreate($oOutlook, "Test Folder 2", $olFolderInbox, "*\Test Folder 1\")_OL_Close($oOutlook) Thanks in advance! Link to comment Share on other sites More sharing options...
water Posted September 4, 2015 Share Posted September 4, 2015 Use _OL_PSTAccess to access the PST and then add the subfolder like you did in your post. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
D-man Posted September 8, 2015 Author Share Posted September 8, 2015 I tried adding the PST access code below, but the folder is still being created in the default data file. Is there a good working example that I could look at to try and figure out what I am missing? Global $oOutlook = _OL_Open(); Access PSTGlobal $oFolder = _OL_PSTAccess($oOutlook, "C:\Users\MyUser\Documents\Outlook Files\My Outlook Data File 1.pst")Global $oFolder = _OL_FolderCreate($oOutlook, "Test Folder 1", $olFolderInbox)_OL_Close($oOutlook) Link to comment Share on other sites More sharing options...
water Posted September 8, 2015 Share Posted September 8, 2015 What is the value of @error after calling _OL_PSTAccess and _OL_FolderCreate? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
D-man Posted September 9, 2015 Author Share Posted September 9, 2015 Hi,I added the error checking lines and don't get any errors. The folder gets successfully created, just not in my PST. Please see code below. Global $oOutlook = _OL_Open(); Access PSTGlobal $oFolder = _OL_PSTAccess($oOutlook, "C:\Users\z151947\Documents\Outlook Files\My Outlook Data File 1.pst")If @error <> 0 Then Exit MsgBox(16, "OutlookEX Example Script", "Error accessing 'My Outlook Data File 1.pst' archive. @error = " & @error & ", @extended: " & @extended)Global $oFolder = _OL_FolderCreate($oOutlook, "Test Folder 1", $olFolderInbox)If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_FolderCreate Example Script", "Error creating folder 'Test-Folder' in folder 'Outlook-UDF-Test\SourceFolder'. @error = " & @error)$oFolder.DisplayMsgBox(64, "OutlookEX UDF: _OL_FolderCreate Example Script", "Folder successfully created!")_OL_Close($oOutlook) Link to comment Share on other sites More sharing options...
water Posted September 9, 2015 Share Posted September 9, 2015 You need to define the folder in which the new one should be created:Global $oFolder = _OL_FolderCreate($oOutlook, "Test Folder 1", $olFolderInbox, $oFolder) My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
D-man Posted September 9, 2015 Author Share Posted September 9, 2015 I replaced:Global $oFolder = _OL_FolderCreate($oOutlook, "Test Folder 1", $olFolderInbox)with:Global $oFolder = _OL_FolderCreate($oOutlook, "Test Folder 1", $olFolderInbox, $oFolder)but the results are the same. I wonder if "$olFolderInbox" is the problem. The example I saw was for creating a new task folder, so I took a guess and replaced "$olFolderTasks" with "$olFolderInbox" to create a new email folder in the default data file and it worked. Link to comment Share on other sites More sharing options...
water Posted September 9, 2015 Share Posted September 9, 2015 So it Looks like that there can only be a single Inbox. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
D-man Posted September 9, 2015 Author Share Posted September 9, 2015 Yes, the inbox is only in my default data file and that's where all my incoming email arrives. I even tried manually adding "Inbox" folder to my PST and run the script, but it didn't work. So, do you think it's just not possible to add a folder to a PST or there is a chance "$olFolderInbox" can be changed to some other value that would work? Link to comment Share on other sites More sharing options...
water Posted September 9, 2015 Share Posted September 9, 2015 I will do some tests as soon as I find some spare time. What you need is a folder with default item type of mail? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
D-man Posted September 9, 2015 Author Share Posted September 9, 2015 Thanks for your help! I am not sure I understand the default item type in context of a personal PST data file. Please see attached image of my Outlook folder structure. Link to comment Share on other sites More sharing options...
water Posted September 10, 2015 Share Posted September 10, 2015 This works fine for me:#include <OutlookEX.au3> Global $oOL = _OL_Open() If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended) Global $oPST = _OL_PSTAccess($oOL, "C:\temp\My Outlook Data File 1.pst", "Outlook-UDF-PST") If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error accessing 'Outlook-UDF-PST\'. @error = " & @error) Global $oFolder = _OL_FolderCreate($oOL, "Test-Folder", $olFolderInbox, $oPST) If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating folder 'Test-Folder' in PST. @error = " & @error) $oFolder.Display MsgBox(64, "OutlookEX UDF", "Folder 'Test-Folder' (Type: tasks) successfully created in PST.") _OL_Close($oOL) My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
D-man Posted September 10, 2015 Author Share Posted September 10, 2015 (edited) Thanks for testing!! Very strange... I tried your code, except for the PST file path, and it still created the new folder in default data file. Interestingly, my default Outlook data file name got changed to "Outlook-UDF-PST" (see attached image), so somehow the PST object access is not working during the folder create.I also attached the Outlook and Windows versions I am running. Global $oOL = _OL_Open() If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended) Global $oPST = _OL_PSTAccess($oOL, "C:\Users\MyUser\Documents\Outlook Files\My Outlook Data File 1.pst", "Outlook-UDF-PST") If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error accessing 'Outlook-UDF-PST\'. @error = " & @error) Global $oFolder = _OL_FolderCreate($oOL, "Test-Folder", $olFolderInbox, $oPST) If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating folder 'Test-Folder' in PST. @error = " & @error) $oFolder.Display MsgBox(64, "OutlookEX UDF", "Folder 'Test-Folder' (Type: tasks) successfully created in PST.") _OL_Close($oOL) Edited September 10, 2015 by D-man Link to comment Share on other sites More sharing options...
water Posted September 10, 2015 Share Posted September 10, 2015 Thanks for testing!! Very strange... I tried your code, except for the PST file path, and it still created the new folder in default data file. Interestingly, my default Outlook data file name got changed to "Outlook-UDF-PST" (see attached image), so somehow the PST object access is not working during the folder create.What do you mean by "default data file"? Is this an Exchange Mailbox, another PST or ...? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
D-man Posted September 10, 2015 Author Share Posted September 10, 2015 Please see attached image. Link to comment Share on other sites More sharing options...
water Posted September 13, 2015 Share Posted September 13, 2015 The only difference I see is that your default data file is a OST. Mine is an Exchange server.Is it possible for you to test with an Exchange mailbox? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
D-man Posted September 14, 2015 Author Share Posted September 14, 2015 I disabled data file caching so Outlook now runs directly from the Exchange Server (see image), but it didn't help.This is the first time I tried OutlookEX UDF, so the first piece of code I ran was to setup the test environment (see below).; ***************************************************************************** ; Create test environment ; ***************************************************************************** ;~ Global $oOutlook = _OL_Open() ;~ If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended) ;~ Global $Result = _OL_TestEnvironmentCreate($oOutlook) ;~ If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF - Manage Test Environment", "Error creating the test environment. @error = " & @error & ", @extended = " & @extended) ; *****************************************************************************This created some hidden objects in my Outlook. I tried to manually cleanup the test environment by temporary modifying OutlookEX UDF to only run the "; Delete existing folder structure" section of the Func _OL_TestEnvironmentCreate. This seemed to have worked, but I am not sure if there is still residue that I don't know about. I wonder if this is messing up the folder create... Link to comment Share on other sites More sharing options...
water Posted September 14, 2015 Share Posted September 14, 2015 To delete the test environment simply run _OL_TestEnvironment.au3.The test environment should not have negative effects on other functions.From the code you posted I see that you no longer call _OL_Open. This might cause the problem My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
D-man Posted September 14, 2015 Author Share Posted September 14, 2015 The test environment snippet was from another file. This is my current script.Global $oOL = _OL_Open() If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended) Global $oPST = _OL_PSTAccess($oOL, "C:\Users\MyUser\Documents\Outlook Files\My Outlook Data File 1.pst", "Outlook-UDF-PST") If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error accessing 'Outlook-UDF-PST\'. @error = " & @error) Global $oFolder = _OL_FolderCreate($oOL, "Test-Folder", $olFolderInbox, $oPST) If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating folder 'Test-Folder' in PST. @error = " & @error) $oFolder.Display MsgBox(64, "OutlookEX UDF", "Folder 'Test-Folder' (Type: tasks) successfully created in PST.") _OL_Close($oOL) I couldn't find _OL_TestEnvironment.au3. Do I have the correct UDF version? ; #INDEX# =======================================================================================================================; Title .........: Microsoft Outlook Function Library (MS Outlook 2003 and later); AutoIt Version : 3.3.9.2 (New COM error handler), runs with 3.3.8.1 too; UDF Version ...: 0.10.0.0; Language ......: English; Description ...: A collection of functions for accessing and manipulating Microsoft Outlook; Author(s) .....: wooltown, water; Modified.......: 20131110 (YYYYMMDD); Contributors ..: progandy (CSV functions taken and modified from http://www.autoitscript.com/forum/topic/114406-csv-file-to-multidimensional-array); Ultima, PsaltyDS for the basis of the __OL_ArrayConcatenate function; Resources .....: Outlook 2003 Visual Basic Reference: http://msdn.microsoft.com/en-us/library/aa271384(v=office.11).aspx; Outlook 2007 Developer Reference: http://msdn.microsoft.com/en-us/library/bb177050(v=office.12).aspx; Outlook 2010 Developer Reference: http://msdn.microsoft.com/en-us/library/ff870432.aspx; Outlook Examples: http://www.vboffice.net/sample.html?cmd=list&mnu=2; ========================================================================================================================= Link to comment Share on other sites More sharing options...
water Posted September 14, 2015 Share Posted September 14, 2015 Version 0.10 is from 2013-11. Please download the newest version 1.0.0.0 dated 2014-07 and try again. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now