Efty Posted November 24, 2015 Posted November 24, 2015 (edited) Hi, i use the latest AutoIt Version combined with the latest Outlook UDF. My following script should export the whole Outlook 2007 content to a new pst-file and works flawless. Except on thing...Every subfolder which resists in a main folder will also be visible in the root of the new pst-file. Here is an quick example...Original PST New PST \contacts \contacts \contacts\business \business \contacts\private \private \contacts\business \contacts\private ... and here's my script.expandcollapse popup; Pfad zum OutlookEx UDF #include <udf\OutlookEx.au3> #include <array.au3> ; SplashText Hinweis für die Dauer des Scripts SplashTextOn("Bitte warten...", "Aktives Postfach wird exportiert...", @DesktopWidth - 40, 45, 20, @DesktopHeight - 100, 5, "") ; Verbindung zu Outlook öffnen Global $oOutlook = _OL_Open() ; Pfad zur PST-Datei $oPSTPfad = @ScriptDir & "\" ; Name der PST-Datei $oPSTName = "[" & @YEAR & "-" & @MON & "-" & @MDAY & "] " & StringUpper(@UserName) ; Evtl. vorhandene PST-Datei löschen If FileExists($oPSTPfad & $oPSTName & ".pst") = TRUE Then FileDelete($oPSTPfad & $oPSTName & ".pst") ; PST-Datei im Unicode-Format erstellen und öffnen $oPST = _OL_PSTCreate($oOutlook, $oPSTPfad & $oPSTName & ".pst", $oPSTName, $olStoreUnicode) ; Alle Ordner des aktiven Postfachs ermitteln $aFolders = _OL_FolderTree($oOutlook, "*") ; Länge der Postfachbezeichnung ermitteln Global $iRoot = StringLen($aFolders[0]) Global $count = UBound($aFolders) - 1 ; Alle Ordner des Postfachs durchlaufen For $i = 1 To UBound($aFolders) - 1 ; Ordner Pfad in der Postfachstruktur ermitteln und 'Erinnerungen' berücksichtigen if $aFolders[$i] <> "Erinnerungen" Then $aFolder = StringRight($aFolders[$i], StringLen($aFolders[$i]) - $iRoot) Else $aFolder = "Erinnerungen" Endif ; Hinweis aktualisieren ControlSetText("Bitte warten...", "", "Static1", "[" & $i & "|" & $count & "] " & StringUpper($aFolder) & " wird exportiert...") ; Inhalt des Ordners in die PST-Datei schreiben _OL_FolderCopy($oOutlook, "*\" & $aFolder, $oPST & "\" & $aFolder) Next ; PST-Datei schliessen _OL_PSTClose($oOutlook, $oPST) ; Outlook schliessen _OL_Close($oOutlook) Can anyone please give me an advice!?Thanx in advance.Kind regardsEfty Edited November 24, 2015 by Efty
water Posted November 24, 2015 Posted November 24, 2015 Could you please set the level for _OL_FolderTree (parameter $iLevel = 1) to 1 and try again?Now _OL_Foltertree returns all levels of folders and _OL_FolderCopy copies the specified folder plus all subfolders. So you are doing it twice at the moment. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Efty Posted November 25, 2015 Author Posted November 25, 2015 (edited) Hi water,first i would to thank you for your quick reply and the fantastic udf. It saved me a lot of time.So - i've done as told. I modified my code, set the folder Level to 1 and removed the Loop through the Folder Array.The script runs without error but the newly created pst-file is empty, but has a size of 271 kbyte.; Include-Dateien #include <udf\OutlookEx.au3> #include <array.au3> ; Verbindung zu Outlook öffnen $oOutlook = _OL_Open() ; Pfad zur PST-Datei $oPSTPfad = @ScriptDir & "\" ; Name der PST-Datei $oPSTName = "[" & @YEAR & "-" & @MON & "-" & @MDAY & "] " & StringUpper(@UserName) ; PST-Datei im Unicode-Format erstellen und öffnen $oPST = _OL_PSTCreate($oOutlook, $oPSTPfad & $oPSTName & ".pst", $oPSTName, $olStoreUnicode) ; Alle Ordner des aktiven Postfachs ermitteln $aFolders = _OL_FolderTree($oOutlook, "*", 1) ; Inhalt des Ordners in die PST-Datei schreiben _OL_FolderCopy($oOutlook, $aFolders[0], $oPST) ; PST-Datei schliessen _OL_PSTClose($oOutlook, $oPST) ; Outlook schliessen _OL_Close($oOutlook)I also replaced the $aFolders[0] in _OL_FolderCopy with "*", "\\Postfach - Edge, Efty", etc. but nothing worked.Can you please help me once again to export the whole Outlook content to a pst-file!?Kind regardsEfty Edited November 25, 2015 by Efty
water Posted November 25, 2015 Posted November 25, 2015 You need to add some error checking. Do you get the expected results (Array, @error always 0)?; Include-Dateien #include <udf\OutlookEx.au3> #include <array.au3> ; Verbindung zu Outlook öffnen $oOutlook = _OL_Open() MsgBox(0, "", "Open: @error = " & @error & ", @extended = " & @extended) ; Pfad zur PST-Datei $oPSTPfad = @ScriptDir & "\" ; Name der PST-Datei $oPSTName = "[" & @YEAR & "-" & @MON & "-" & @MDAY & "] " & StringUpper(@UserName) ; PST-Datei im Unicode-Format erstellen und öffnen $oPST = _OL_PSTCreate($oOutlook, $oPSTPfad & $oPSTName & ".pst", $oPSTName, $olStoreUnicode) MsgBox(0, "", "PST create: @error = " & @error & ", @extended = " & @extended) ; Alle Ordner des aktiven Postfachs ermitteln $aFolders = _OL_FolderTree($oOutlook, "*", 1) MsgBox(0, "", "Foldertree: @error = " & @error & ", @extended = " & @extended) _ArrayDisplay($aFolders) ; Inhalt des Ordners in die PST-Datei schreiben _OL_FolderCopy($oOutlook, $aFolders[0], $oPST) MsgBox(0, "", "Foldercopy: @error = " & @error & ", @extended = " & @extended) ; PST-Datei schliessen _OL_PSTClose($oOutlook, $oPST) MsgBox(0, "", "PST close: @error = " & @error & ", @extended = " & @extended) ; Outlook schliessen _OL_Close($oOutlook) My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Efty Posted November 25, 2015 Author Posted November 25, 2015 I redirected the Errors to the console, here is what it Looks likeOpen: @error = 0, @extended = 0 PST create: @error = 0, @extended = 0 Foldertree: @error = 0, @extended = 0 Foldercopy: @error = 1, @extended = 1 PST close: @error = 0, @extended = 0 [Finished in 2.2s]and the ArrayDisplay shows followingRow Col 0 [0] \\Postfach - Edge, EftyI hope it helps.Efty
water Posted November 25, 2015 Posted November 25, 2015 (edited) How many entries do you have in the displayed array? Only one? Edited November 25, 2015 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Efty Posted November 25, 2015 Author Posted November 25, 2015 Right, only One. If i remove the $iLevel Parameter i See the root folder structure under \\Postfach - Edge, Efty. But then i have double entries
water Posted November 26, 2015 Posted November 26, 2015 Fine. Then I suggest to use$aFolders = _OL_FolderTree($oOutlook, "*", 2)and ignore the root directory\\Postfach - Edge, EftyTo copy the remaining folders you need to remove the leading "\\". My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Efty Posted November 28, 2015 Author Posted November 28, 2015 (edited) Hi water,thank you very, very much. Now it works like charm. Here for all there are interested in the solution the complete code.expandcollapse popupPfad zum OutlookEx UDF #include <udf\OutlookEx.au3> #include <array.au3> ; SplashText Hinweis für die Dauer des Scripts SplashTextOn("Bitte warten...", "Aktives Postfach wird exportiert...", @DesktopWidth - 40, 45, 20, @DesktopHeight - 100, 5, "") ; Verbindung zu Outlook öffnen Global $oOutlook = _OL_Open() ; Pfad zur PST-Datei $oPSTPfad = @ScriptDir & "\" ; Name der PST-Datei $oPSTName = "[" & @YEAR & "-" & @MON & "-" & @MDAY & "] " & StringUpper(@UserName) ; Evtl. vorhandene PST-Datei löschen If FileExists($oPSTPfad & $oPSTName & ".pst") = TRUE Then FileDelete($oPSTPfad & $oPSTName & ".pst") ; PST-Datei im Unicode-Format erstellen und öffnen $oPST = _OL_PSTCreate($oOutlook, $oPSTPfad & $oPSTName & ".pst", $oPSTName, $olStoreUnicode) ; Alle Ordner des aktiven Postfachs ermitteln $aFolders = _OL_FolderTree($oOutlook, "*", 2) ; Länge der Postfachbezeichnung ermitteln Global $iRoot = StringLen($aFolders[0]) Global $count = UBound($aFolders) - 1 ; Alle Ordner des Postfachs durchlaufen For $i = 1 To UBound($aFolders) - 1 ; Ordner Pfad in der Postfachstruktur ermitteln und 'Erinnerungen' berücksichtigen if $aFolders[$i] <> "Erinnerungen" Then $aFolder = StringRight($aFolders[$i], StringLen($aFolders[$i]) - $iRoot) Else $aFolder = "Erinnerungen" Endif ; Hinweis aktualisieren ControlSetText("Bitte warten...", "", "Static1", "[" & $i & "|" & $count & "] " & StringUpper($aFolder) & " wird exportiert...") ; Inhalt des Ordners in die PST-Datei schreiben _OL_FolderCopy($oOutlook, "*\" & $aFolder, $oPST & "\" & $aFolder) Next ; PST-Datei schliessen _OL_PSTClose($oOutlook, $oPST) ; Outlook schliessen _OL_Close($oOutlook) Kind regards and thumbs up to the very good support!Efty Edited November 28, 2015 by Efty
water Posted November 28, 2015 Posted November 28, 2015 Glad to be of service Schöne Grüße My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
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