# OutlookEX UDF (Question, not error)

## 12 posts in this topic

Howdy!

I've been reading through the OutLookEX documentation and examples for the past two days ( VERY well documented, very clear! )

But I've had trouble locating information on specifying what user to use. My outlook is linked to two email accounts and I can only manipulate the main account's stuff. A simple script I've been playing with is this

; Include Functions
#include <OutlookEX.au3>

; Connect to Outlook
Global $oOutlook = _OL_Open() If @error <> 0 Then Exit MsgBox(16, "Connect to Outlook", "Error connecting to Outlook. @error = " & @error & ", @extended = " & @extended) ;List the folders Global$aResult = _OL_FolderTree($oOutlook, "*") If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_FolderTree Example Script", "Error accessing root folder. @error = " & @error) _ArrayDisplay($aResult, "OutlookEX UDF: _OL_FolderTree Example Script - All folders")

It works like a charm but it only returns my main account's folders.

I really hope I didn't overlook a wiki page or help file...

Any assistance would be greatly appreciated!

-Reiz

##### Share on other sites

Should I repost this in this forum thread?

##### Share on other sites

No problem starting a new thread
"*" is always resolved to the current user. Check the help file for _OL_FolderAccess and you will see how to access the folder of another user. Call _OL_FolderAccess and then pass the returned folder object to _OL_FolderTree.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-02-03 - Version 1.4.7.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:

##### Share on other sites

Hey there!

Thank you for the guidance. What you have made is amazingly helpful ( or soon will be ) to my daily work life.

I am going to dig into those docs and see what I come up with.

Cheers!

-Reiz

##### Share on other sites

Ah! I discovered the actual dilemma I am hitting!

The area I am trying to access isn't a user account, it is just a "General Mailbox" meaning it has none of the usual functions of a normal user. Until 10 minutes ago I didn't know anything like this existed.

At any rate if I can't specify a person/user , any ideas on how I can gain access to a set of folders that aren't exactly associated with a user account?

When I right click on one of my own personal folders and click Properties , it gives me a location of  "\\myemail@mydomain.com"

When I right click on the mailbox's folder that I want to get into and click Properties it gives me a location of "\\thename"  (( Not a blah@blue.com , just blah))

I used "thename" in the script and it returns with Error 1 which means to me that it can't access the specified root folder.

; Include Functions
#include <OutlookEX.au3>

; Connect to Outlook
Global $oOutlook = _OL_Open() If @error <> 0 Then Exit MsgBox(16, "Connect to Outlook", "Error connecting to Outlook. @error = " & @error & ", @extended = " & @extended) ;List the folders Global$aResult = _OL_FolderTree($oOutlook, "\\NAMEHERE") If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_FolderTree Example Script", "Error accessing root folder. @error = " & @extended) _ArrayDisplay($aResult, "OutlookEX UDF: _OL_FolderTree Example Script - All folders")

If there is information I am leaving out that would be useful to you just let me know and I will try to find it. Thank you very much for your time!

##### Share on other sites

In the folder tree of Outlook at the root of the mailbox you want to access you see the name. Use this in _OL_FolderAccess.
Example:

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-02-03 - Version 1.4.7.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:

##### Share on other sites

Hey there,

I really appreciate you spending time with me on this and helping me work through dillemma. I know you could be spending it doing ANYTHING else so I really do value you taking the time to respond to me. Thank you.

I made the modifications as you suggested

; Include Functions
#include <OutlookEX.au3>

; Connect to Outlook
Global $oOutlook = _OL_Open() If @error <> 0 Then Exit MsgBox(16, "Connect to Outlook", "Error connecting to Outlook. @error = " & @error & ", @extended = " & @extended) Global$aFolder = _OL_FolderAccess($oOutlook, "\\NAME\Inbox",$olFolderInbox)
if @error then MsgBox(0, "Error", "Error returned by _OL_FolderAccess: " & @error & "-" & @extended)

;List the folders
Global $aResult = _OL_FolderTree($oOutlook, $aFolder) If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_FolderTree Example Script", "Error accessing root folder. @error = " & @extended) _ArrayDisplay($aResult, "OutlookEX UDF: _OL_FolderTree Example Script - All folders")

And I get back an "Error Accessing Root Folder , Error = 0"

Again thank you very much for your time regarding this.

##### Share on other sites

Unfortunately _OL_FolderAccess returns an array. So the statement should be:

;List the folders
Global $aResult = _OL_FolderTree($oOutlook, $aFolder[1]) My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2017-02-03 - Version 1.4.7.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki #### Share this post ##### Link to post ##### Share on other sites Well that returned a different error it seems! I should have known to call it as an array, thank you for reminding me. This is what I get when I try to run it now "C:\directorystuff\mail\OutlookEX.au3" (1259) : ==> The requested action with this object has failed.:$oFolder = $oNamespace.GetSharedDefaultFolder($oDummy, $iFolderType).Parent$oFolder = $oNamespace^ ERROR >Exit code: 1 Time: 2.633 Did I break your UDF? o.o I'm sorry!!! #### Share this post ##### Link to post ##### Share on other sites #10 · Posted (edited) You didn't break the UDF - that's not possible Could you please try: Global$aFolder = _OL_FolderAccess($oOutlook, "NAME\") Edited by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2017-02-03 - Version 1.4.7.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki #### Share this post ##### Link to post ##### Share on other sites Howdy It worked! It worked it worked it worked! I literally jumped up in excitement and scared my fellow co-workers LOL Thank you very much! -Reiz #### Share this post ##### Link to post ##### Share on other sites Now your fellow co-workers know how easy AutoIt is My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2017-02-03 - Version 1.4.7.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki #### Share this post ##### Link to post ##### Share on other sites ## 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 account ## Sign in Already have an account? Sign in here. Sign In Now • ### Similar Content • By Smigacznr1 I'm writing Outlook pst cleaner and now I'm stuck. Compiled script is crashing with OS crash message. When I tryied to run script from editor it's exiting itself (mabye it's some type of crash?) always when it's processing on 4-rd pst file. Here is my code: #include <OutlookEX.au3> #include <Date.au3> #include <File.au3> #include <Array.au3> _cleanOutlook("Administrator") _cleanOutlook("Admin") Exit Func _cleanOutlook($user) $foldery = "Wiadomości-śmieci#?SPAM#?Junk E-mail#?Elementy usunięte#?Deleted Items"$tab_folderow = StringSplit($foldery, "#?", 1)$tab_pst = _FileListToArrayRec("c:\users\" & $user, "*.pst", 1+4+8, 1, 0, 2) ;~ _ArrayDisplay($tab_pst) For $d = 1 To UBound($tab_pst) -1 Step +1 $outlook = _OL_Open(True) _OL_Close($outlook, True) $outlook = _OL_Open() Local$aStores = _OL_StoreGet($outlook) ;~ _ArrayDisplay($aStores) For $i = 1 to$aStores[0][0] If $aStores[$i][4] = True Then ;~ ConsoleWrite(@CRLF & "zamykam pst 2") _OL_PSTClose($outlook,$aStores[$i][0]) EndIf Next ;~ _OL_PSTAccess($outlook, "C:\Users\Administrator\Desktop\cos.pst") _OL_PSTAccess($outlook,$tab_pst[$d]) ConsoleWrite(@CRLF &$tab_pst[$d]) ;~$tab_struktury = _OL_FolderTree($outlook, "*", 10) ;~ If @error Then ;~ ContinueLoop ;~ EndIf ;~ _ArrayDisplay($tab_struktury) $tab_ktory_pst = _OL_PSTGet($outlook) ;~ _ArrayDisplay($tab_ktory_pst) For$a = 0 To UBound($tab_ktory_pst) -1 Step +1 If$tab_ktory_pst[$a][2] =$tab_pst[$d] Then ;~ MsgBox(0, "",$tab_ktory_pst[$a][0])$nazwa_bazy_pst = $tab_ktory_pst[$a][0] EndIf Next ;~ MsgBox(0, "", UBound($tab_folderow)) ;~ _ArrayDisplay($tab_folderow, $tab_pst[$d]) ConsoleWrite(@CRLF & "przed while") $a = 0 While$a < 2 ConsoleWrite(@CRLF & "while 1") For $b = 1 To UBound($tab_folderow) -1 Step +1 ConsoleWrite(@CRLF & "for 1") $tab_struktury = _OL_FolderTree($outlook, $nazwa_bazy_pst) ;~ _ArrayDisplay($tab_struktury, $nazwa_bazy_pst) ;~$folder = _OL_FolderAccess($outlook, StringTrimLeft($tab_struktury[0], 2) & "\" & $tab_folderow[$b]) $folder = _OL_FolderAccess($outlook, $nazwa_bazy_pst & "\" &$tab_folderow[$b]) ;~ ConsoleWrite(@CRLF & "eeee") If @error Then ;~ MsgBox(0, "", "\\" &$nazwa_bazy_pst & "\" & $tab_folderow[$b] & @CRLF & @error) ConsoleWrite(@CRLF & "przechodze do kolejnego " & $b+1) ContinueLoop EndIf ;~ _ArrayDisplay($folder, $nazwa_bazy_pst) ConsoleWrite(@CRLF &$tab_folderow[$b]) If$tab_folderow[$b] = "Deleted Items" Or$tab_folderow[$b] = "Elementy usunięte" Then ConsoleWrite(@CRLF & "usuwam kosze") _OL_FolderDelete($outlook, $folder[1], 1) _OL_FolderDelete($outlook, $folder[1], 2) _OL_FolderDelete($outlook, $folder[1], 3) _OL_FolderDelete($outlook, $folder[1], 4) ;~ _OL_FolderDelete($outlook, $folder[1], 5) EndIf If$a = 0 Then $tab_maile = ""$data_dzis = @YEAR & "/" & @MON & "/" & @MDAY & " 00:00" ;~ $data_dzis = "2017/01/31 00:00"$data_szukana = _DateAdd("D", "-3", $data_dzis)$tab_maile = _OL_ItemFind($outlook,$folder[1], $olMail, "[Received]<'" & StringReplace($data_szukana, "/", "-") & "'", "", "", "EntryID", "", 1) If @error Then ContinueLoop EndIf ;~ If UBound($tab_maile) > 1 Then ;~ _ArrayDisplay($tab_maile) ;~ EndIf If UBound($tab_maile) > 1 Then For$c = 1 To UBound($tab_maile) -1 Step +1 ;~ ConsoleWrite(@CRLF & "usuwam stare maile") _OL_ItemDelete($outlook, $tab_maile[$c][0], "", False) Next EndIf EndIf Next $a =$a + 1 WEnd ;~ ConsoleWrite(@CRLF & "pokazuje") ;~ $folder[1].Display$olFolderInbox.Display ;~ _OL_PSTClose($outlook,$olFolderInbox) ;~ If @error Then ;~ MsgBox(0, "", @error) ;~ EndIf Local $aStores = _OL_StoreGet($outlook) ;~ _ArrayDisplay($aStores) For$i = 1 to $aStores[0][0] If$aStores[$i][4] = True Then ;~ ConsoleWrite(@CRLF & "zamykam pst 1") _OL_PSTClose($outlook,$aStores[$i][0]) EndIf Next ;_OL_PSTClose($outlook,$folder[1]) _OL_Close($outlook, True) If @error Then MsgBox(0, "", @error) EndIf ConsoleWrite(@CRLF & "zamykam") ProcessWaitClose("outlook.exe", 30) ProcessClose("outlook.exe") Next EndFunc Outlook and OS is updated. I'm usinn OutlooEX in ver. 1.3.1.0 Any ideas? • By FrancescoDiMuro Good morning I would like to know if I can use the Excel UDF to manipulating a .csv file without having Office installed on the PC I'm going to work... I read somewhere that it could be done, but I'm here to ask and be sure of what I remember... I'd like to post another question... How can I retrieve the handle of a windows from a PID of an .exe? I have my script that does a ShellExecute ( which returns the PID of the .exe ), and then, switching a parameter read from a .ini file, adapt the Window on the screen ( Maximize, Minimize, On Top )... I tried, but without having success with this: #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile_x64=prova.exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <AutoItConstants.au3> #include <WinAPIEx.au3> #include <Array.au3> Local$sFileConfigurazione = @ScriptDir & "\configurazione_exe.ini" If(FileExists($sFileConfigurazione)) Then Local$aSezioniIni = IniReadSection($sFileConfigurazione, "CONFIGURAZIONE_EXE") If @error Then MsgBox($MB_ICONERROR, "Errore!", "Errore durante l'apertura del file: " & @CRLF & $sFileConfigurazione & @CRLF & "Errore: " & @error) Else ; Lancio dell'applicativo indicato nel file di configurazione Local$iPID = ShellExecute($aSezioniIni[1][1]) Local$hWnd If($iPID <> 0) Then Local$aWinList = WinList() For $i = 1 To$aWinList[0][0] If(WinGetProcess($aWinList[$i][1] = $iPID)) Then$hWnd = $aWinList[$i][1] EndIf Next Switch($aSezioniIni[2][1]) Case$aSezioniIni[2][1] = "MIN" WinSetState($hWnd, "", @SW_MINIMIZE) Case$aSezioniIni[2][1] = "MAX" WinSetState($hWnd, "", @SW_MAXIMIZE) Case$aSezioniIni[2][1] = "TOP" WinSetOnTop($hWnd, "",$WINDOWS_ONTOP) EndSwitch EndIf EndIf EndIf It just set on top the .exe I'm launching...
Thanks
• By Gowrisankar
Dear members of the forum,
I'm new to AutoIt and I'm having a good time exploring and enjoying the features of AutoIt.
For one of my tasks, I've to open few particular mails from outlook based on subject of the mails and then print the mails. Can someone please guide me how to do it?
My question could be very silly for experts. But I'm just a beginner. Kindly advice.
Thanks and regards,
Gowrisankar R.
• By TheSaint
I had a need, and so I developed.
Before I did that though, I did a quick search of the forum, and found a few things, but none seemed to suit what I really wanted ... though to be honest, I did not investigate them deeply or search extensively. In any case, I am not very good at modifying the code of others, nor do I enjoy doing so, so in the end I decided it was best to start from scratch ... re-inventing the wheel perhaps, but a wheel I feel a certain degree of comfort with. I also thought about Maps, but don't know enough.
_IniString Functions (was Ini_InMem)
Ini in memory
Settings INI - Read/Write once to the disk
INI File Processing Functions
... sure to be others.
As with all my stuff, feel free to use (no guarantees) or modify ... just give me credit where due.
I always go for the quick & simple approach, as those who know me here, are well aware, so without a doubt, my code could be improved - sped up, RegExp used, etc. So feel free to do that, and convert into a proper UDF, if you want, following best practices etc, as I am sure others will appreciate it.
Recently, I have come upon a need to extract data from an approximately 50 Mb downloaded Index file, just extracting the few elements I need, and storing them in an INI file. It is quite a time consuming process, especially on my underpowered Netbook, which is where I am using the program I built. I have been considering ways to speed up things. Two good sounding methods, out of several possibles, have come to mind - 1) RAM Disk and 2) Virtual INI processing. That last being a better option, when sharing code (program) with others.
Another method, which I am currently using, that did give me some measurable benefit, was to download the almost 50 Mb Index file in Stages (i.e. 30 x 1.4 Mb roughly), extracting data from each in turn. I have also considered extracting to 10 (or 11) separate INI files, rather than the single large INI file (4~5 Mb), as things noticeably slow up as the INI file increases in size ... obviously due to writing time.
I can't really speed up the extraction process, but that last method may speed up the writing stage.  However, it would require significant program changes, and perhaps not gain me much benefit. To complicate things, there are too many Section names (Index ID's) for the IniReadSectionNames command, so I have had to split them off into their own (read/write) line-by-line index file, and create code to deal with duplicates. When read, Index ID's and Titles populate a Listbox control in a user GUI.
So at this point in time, it seems best to use the Virtual INI approach to gain a significant reduction in time taken. For my own specific use, with my slow Netbook, I may also use a RAM Disk.
Due to the aforementioned INI issues, and lack of available specific data, probably because it is always  program concentric, I have created an ASCII Checker program, which I guess you can say, is AutoIt  concentric. Because others may also find it handy, I am providing it here. NOTE - As yet, I am only aware that Escape characters exist, but have not investigated or catered for them in any way.
ASCII Checker.zip

The Virtual_INI_UDF is still a work in progress, though I have done most of the functions now, with the working but incomplete _Ini_Test function, still requiring changes etc from the information gleaned by the ASCII Checker program.
Here's something to play with meanwhile.
Updated files (24th February 2017)
Virtual_INI_UDF.au3  NEW
Example.au3 (23rd February 2017)
All pretty basic, but managed to load my 4 Mb INI file (seemingly ok, but took a few seconds) ... though I have only worked with much smaller testing ones so far.
P.S. While I have done a fair amount of testing, it has been pretty basic, and mostly limited to the examples provided. Testing has definitely not been extensive.

• By rcmaehl
A UDF with Extended Functions for Window Management

DISCLAIMER:
This UDF is still in the development phase. All code works and should be generally bug free, however function names and parameters are subject to change.

Notes:
Fixes _WindowGetClassList's barbaric returning of a @LF separated string instead of an array.

Potential Uses:
Automating applications that change their controls' handles/classes on each launch (e.g. half of Cisco's programs)

Functions:
_WinGetClassList
_WinGetClassNNList
_WindowGetHandleList
_WindowGetHandleListFromPos

10/04/2016 (v0.4): _WinGetClassNNList Fixed : Not Returning an Index when using $2D_ARRAY _WinGetClassNNList Fixed : Not Properly returning$aArray[x][1] on Classes with instances > 9 when using $2D_ARRAY 10/03/2016 (v0.3): _WinGetClassList Added : Exactly the same as WinGetClassList but returns a more civilized Array _WinGetClassNNList Added : Returns Classes and their instances in either a 1D or 2D array depending on Flags _WindowGetHandleList Renamed: _WinGetHandleList SCRIPT BREAKING! _WindowGetHandleListFromPos Renamed: _WinGetHandleListFromPos SCRIPT BREAKING! 10/01/2016 (v0.2): WindowsExConstants.au3 Added : Flags in _WindowGetHandleListFromPos _WindowGetHandleListFromPos Removed: ConsoleWrite left in during debug _WindowGetHandleListFromPos Added : Flag for if part of a Control is at$X, \$Y return it as well. 10/01/2016 (v0.1): _WindowGetHandleList Added : Retrieves the handles of classes from a window. _WindowGetHandleListFromPos Added : Retrieves the handles of classes at a specific position from a window. Known and Reported Bugs: