Neutro Posted May 1, 2013 Share Posted May 1, 2013 Hey water, first thanks a lot to wooltown and you for this great UDF I'm trying to find a way to automaticly export all Exchange offline data from an outlook profile to a .pst file for backup. So pretty much what Outlook is doing using the "Import/Export tool". I looked at the manual of the function "_OL_ItemExport", and in the example is described a way to export to a .csv file but nothing about .pst Is it possible to do this using your UDF? Thanks in advance for your help Identify active network connections and change DNS server - Easily export Windows network settings Clean temporary files from Windows users profiles directories - List Active Directory Groups members Export content of an Outlook mailbox to a PST file - File patch manager - IRC chat connect example Thanks again for your help Water! Link to comment Share on other sites More sharing options...
water Posted May 1, 2013 Author Share Posted May 1, 2013 _OL_ItemExport is used to write items to the file system. You want to write items to another store (PST file) so _OL_ItemCopy is what you are looking for. 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 Link to comment Share on other sites More sharing options...
Neutro Posted May 1, 2013 Share Posted May 1, 2013 (edited) Well I'm having a hard time trying to get it working >_< So if I understand correctly I need to copy every items of every folders of the exchange store to a pst file using OL_Item_Copy? If so, how can i get a list of all folders of a store? I tried using: OL_FolderFind($oOutlook, "\\path_to_exchange_store", 99,"","",$olMailItem) but the returned array is empty #Edit: nevermind, i just found out about OL_FolderTree on previous forum page I'll try to get this working now Edited May 1, 2013 by Neutro Identify active network connections and change DNS server - Easily export Windows network settings Clean temporary files from Windows users profiles directories - List Active Directory Groups members Export content of an Outlook mailbox to a PST file - File patch manager - IRC chat connect example Thanks again for your help Water! Link to comment Share on other sites More sharing options...
water Posted May 1, 2013 Author Share Posted May 1, 2013 So if I understand correctly I need to copy every items of every folders of the exchange store to a pst file using OL_Item_Copy?Correct. Unfortunately there is no function available to do what you need with a single call. Maybe an example can be created later. 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 Link to comment Share on other sites More sharing options...
Neutro Posted May 1, 2013 Share Posted May 1, 2013 (edited) Woot I finally managed to do what I wanted like this: expandcollapse popup#include <OutlookEX.au3> #include <Array.au3> #include <File.au3> SplashTextOn("Please wait","Mailbox sync in progress." & @CRLF & @CRLF & "If a window asking for your ID and password pops-up," & @CRLF & "please enter them and click on OK." & @CRLF & @CRLF & "Once you entered your ID and password or if they were not asked," & @CRLF & "please do not use your computer while this window is showing." & @CRLF & @CRLF & "Sync time is approximatively around 1 min.",600,215,-1,-1,18) $outlook = _OL_Open(True) sleep(2000) $pst = _OL_PSTCreate($outlook, @UserProfileDir & "\exchangebackup\exchangebackup.pst", "Exchange backup ") sleep(2000) _OL_ItemSync($Outlook) _OL_ItemSendReceive($Outlook) $folders = _OL_FolderTree($outlook, "*") ;first use of FolderTree is needed to force sync with Exchange server sleep(30000) ; giving 30s to the client to sync items with the Exchange server SplashTextOn("Please wait","Mailbox backup in progress." & @CRLF & @CRLF & "If a window asking for your ID and password pops-up," & @CRLF & "please enter them and click on OK." & @CRLF & @CRLF & "Once you entered your ID and password or if they were not asked," & @CRLF & "please do not use your computer while this window is showing." & @CRLF & @CRLF & "Backup time depends on how large your mailbox is.",600,215,-1,-1,18) $folders = _OL_FolderTree($outlook, "*", 2) If IsArray($folders) then for $i = 2 to UBound($folders) - 1 step 1 if stringinstr(stringmid($folders[$i], 3), stringmid($folders[0], 3)) <> 0 then $current_folder = _OL_FolderAccess($outlook, stringmid($folders[$i], 3)) if IsArray($current_folder) then _OL_FolderCopy($outlook, $current_folder[1], $pst) endif next endif _OL_Close($outlook) SplashOff()I was going to say "Thanks again for your help Water", but since i'm saying this like almost every time i need help here, I added it to my signature so I don't need to write it everytime now I noticed something strange while developping this: the _OL_FolderTree will work perfectly if used on an Outlook client on which the user is already logged on or in offline mode, but if used when the Outlook client is in a state of needed user authentification (this happens when you click on "cancel" when asked for login/password for exchange account), then one of the array row will be blank. That's why i included a check in the above script so if the folder name does not include user root folder inside, it won't try to copy it. Edited May 28, 2013 by Neutro Identify active network connections and change DNS server - Easily export Windows network settings Clean temporary files from Windows users profiles directories - List Active Directory Groups members Export content of an Outlook mailbox to a PST file - File patch manager - IRC chat connect example Thanks again for your help Water! Link to comment Share on other sites More sharing options...
water Posted May 2, 2013 Author Share Posted May 2, 2013 Hi Neutro, thanks for adding me to your signature If the user "clicks on 'cancel' when asked for login/password for exchange account" _OL_Open should return an error because logon wasn't successful. Can you please check the value of @error after _OL_Open? BTW: Which version of Outlook do you run? 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 Link to comment Share on other sites More sharing options...
Neutro Posted May 2, 2013 Share Posted May 2, 2013 @error value is 0. Also I noticed that the Exchange credential window pops up only when _OL_FolderTree is called, not just after _OL_Open(). I tried it on Outlook 2010 and 2013. Identify active network connections and change DNS server - Easily export Windows network settings Clean temporary files from Windows users profiles directories - List Active Directory Groups members Export content of an Outlook mailbox to a PST file - File patch manager - IRC chat connect example Thanks again for your help Water! Link to comment Share on other sites More sharing options...
water Posted May 2, 2013 Author Share Posted May 2, 2013 Could you please try this stripped down script? I tested _OL_FolderTree here and it works jsut fine. #include <OutlookEX.au3> #include <Array.au3> #include <File.au3> SplashTextOn("Please wait", "Mailbox sync in progress." & @CRLF & @CRLF & "If a window asking for your ID and password pops-up," & @CRLF & "please enter them and click on OK." & @CRLF & @CRLF & "Once you entered your ID and password or if they were not asked," & @CRLF & "please do not use your computer while this window is showing." & @CRLF & @CRLF & "Sync time is approximatively around 1 min.", 600, 215, -1, -1, 18) $outlook = _OL_Open(True) If @error Then Exit MsgBox(0, "Error", "_OL_Open: @error = " & @error & ", @extended = " & @extended) $pst = _OL_PSTCreate($outlook, @UserProfileDir & "\exchangebackup\exchangebackup.pst", "Exchange backup") If @error Then Exit MsgBox(0, "Error", "_OL_PSTCreate: @error = " & @error & ", @extended = " & @extended) SplashTextOn("Please wait", "Mailbox backup in progress." & @CRLF & @CRLF & "If a window asking for your ID and password pops-up," & @CRLF & "please enter them and click on OK." & @CRLF & @CRLF & "Once you entered your ID and password or if they were not asked," & @CRLF & "please do not use your computer while this window is showing." & @CRLF & @CRLF & "Backup time depends on how large your mailbox is.", 600, 215, -1, -1, 18) $folders = _OL_FolderTree($outlook, "*") If @error Then Exit MsgBox(0, "Error", "_OL_FolderTree: @error = " & @error & ", @extended = " & @extended) For $i = 2 To UBound($folders) - 1 Step 1 If StringInStr(StringMid($folders[$i], 3), StringMid($folders[0], 3)) <> 0 Then $current_folder = _OL_FolderAccess($outlook, StringMid($folders[$i], 3)) If @error Then Exit MsgBox(0, "Error", "_OL_FolderAccess for folder: " & $folders[$i] & ". @error = " & @error & ", @extended = " & @extended) _OL_FolderCopy($outlook, $current_folder[1], $pst) If @error Then Exit MsgBox(0, "Error", "_OL_FolderCopy for folder: " & $folders[$i] & ". @error = " & @error & ", @extended = " & @extended) EndIf Next _OL_Close($outlook) SplashOff() 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 Link to comment Share on other sites More sharing options...
Neutro Posted May 2, 2013 Share Posted May 2, 2013 The above code will not sync Outlook with the exchange server before making the copy of the folders even if you enter the correct credentials.For this to work, I need to use a first _OL_FolderTree that will open the credential window, then wait 30s so the outlook client has enough time to sync with the server, then use _OL_FolderTree again to get the updated folder list. But that is not a problem since it's still working this way.What I could need is a way to find out if a user pressed cancel on the authentication window or not. Identify active network connections and change DNS server - Easily export Windows network settings Clean temporary files from Windows users profiles directories - List Active Directory Groups members Export content of an Outlook mailbox to a PST file - File patch manager - IRC chat connect example Thanks again for your help Water! Link to comment Share on other sites More sharing options...
water Posted May 2, 2013 Author Share Posted May 2, 2013 I removed the sync part because I wanted to have a simple reproducer. If copying the folders to a PST works then we can add the sync part again. My above example doesn't sync but does it do the copy job correct? 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 Link to comment Share on other sites More sharing options...
Neutro Posted May 2, 2013 Share Posted May 2, 2013 Yes it does that perfectly Identify active network connections and change DNS server - Easily export Windows network settings Clean temporary files from Windows users profiles directories - List Active Directory Groups members Export content of an Outlook mailbox to a PST file - File patch manager - IRC chat connect example Thanks again for your help Water! Link to comment Share on other sites More sharing options...
water Posted May 2, 2013 Author Share Posted May 2, 2013 Fine. So we now need a way to connect to Exchange and get the latest mails before we start the backup.Looks like _OL_SendReceive should do this according to microsoft. So _OL_ItemSync is not necessary.If you manually run Outlook in online mode do you need to enter userid/password as well? 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 Link to comment Share on other sites More sharing options...
Neutro Posted May 3, 2013 Share Posted May 3, 2013 No, as well as if I check the box "remember ID" after one login. I tried using _OL_SendReceive and _OL_Sync before using _OL_TreeView but it doesn't do much. Identify active network connections and change DNS server - Easily export Windows network settings Clean temporary files from Windows users profiles directories - List Active Directory Groups members Export content of an Outlook mailbox to a PST file - File patch manager - IRC chat connect example Thanks again for your help Water! Link to comment Share on other sites More sharing options...
water Posted May 3, 2013 Author Share Posted May 3, 2013 You could try and provide the password with _OL_Open as 6th parameter. 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 Link to comment Share on other sites More sharing options...
Vernie Posted May 3, 2013 Share Posted May 3, 2013 Hay there folks When i run my script from Scite editor it works like a charm.but when i try to send an email after i compiled my program i get the error.error create connection to outlook @error =1, extended = -2146959355It is driving me nuts..Below a part of my script..expandcollapse popupGUICreate("Feature Request", 633, 447, 192, 124) $Edit1 = GUICtrlCreateEdit("", 32, 24, 569, 353) GUICtrlSetData(-1, "") $OK = GUICtrlCreateButton("OK", 32, 400, 113, 25, $WS_GROUP) $CANCEL = GUICtrlCreateButton("Cancel", 480, 400, 121, 25, $WS_GROUP) Case $requestform Switch $msg[0] Case $GUI_EVENT_CLOSE GUIDelete($requestform) GUISetState(@SW_SHOW, $mainform) Case $OK Call ("SendRequest") GUIDelete($requestform) GUISetState(@SW_SHOW, $mainform) Case $CANCEL GUIDelete($requestform) GUISetState(@SW_SHOW, $mainform) EndSwitch EndSwitch WEnd Func SendRequest() $oOL = _OL_Open() If @error <> 0 Then Exit MsgBox(16, "Test", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended) $sTo = "me@domain.nl" $sSubject = "Subject program x" $sBody = (GUICtrlRead($Edit1) & @CRLF) If @error = 1 Then Exit _OL_Wrapper_SendMail($oOL, $sTo, "", "", $sSubject, $sBody) If @error <> 0 Then MsgBox(16, "Test", "Error sending mail. @error = " & @error & ", @extended: " & @extended) _OL_Close($oOL) endfunc Link to comment Share on other sites More sharing options...
water Posted May 3, 2013 Author Share Posted May 3, 2013 Welcome to AutoIt and the forum! Can you please tell me wich Operating System (Windows 7, Windows XP ...), which version of Outlook and which version of AutoIt you run ? 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 Link to comment Share on other sites More sharing options...
Vernie Posted May 3, 2013 Share Posted May 3, 2013 Thnx for the warm welcome.. I have installed SciTe version 3.3.0 with autoit V3 We are using windows 8 x64 with outlook 2013. Link to comment Share on other sites More sharing options...
water Posted May 3, 2013 Author Share Posted May 3, 2013 Do you run the 32bit or 64bit version of Outlook 2013? I run my scripts on WIndows 7 64bit and Office 2010 32bit without problems. 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 Link to comment Share on other sites More sharing options...
Vernie Posted May 3, 2013 Share Posted May 3, 2013 Im running the 2013 32 bits version... The weird thing is that the error only occurs after i compiled to a executable. im installing office 2010 on my virtual machine and will test the exectuble in the virtual box. Link to comment Share on other sites More sharing options...
Vernie Posted May 3, 2013 Share Posted May 3, 2013 (edited) Ok i've tested in on my virtual box with Windows 7 64 bits and outlook 2010 (both 64 and 32 bits). Both are working without any problems. seems that my programs has a problem with outlook 2013 or windows 8 Edited May 3, 2013 by Vernie Link to comment Share on other sites More sharing options...
Recommended Posts