# 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-04-18 - Version 1.4.8.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-04-18 - Version 1.4.8.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-04-18 - Version 1.4.8.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-04-18 - Version 1.4.8.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-04-18 - Version 1.4.8.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 Gowrisankar Good day to the members of the forum.. Is there any UDF that is available to automate Attachmate Extra Mainframe sessions? I am trying to automate mainframe processes. I couldn't get values from particular co-ordinates in mainframe or pass values to particular co-ordinates in mainframe. Please let me know if there is any UDF or any other kind of solution is available. Thanks and regards, Gowrisankar R. • By zetaimmersion Hi all. I am trying to do 2 things but i cannot seem to get any traction on how to read/implement this idea. Premise: PowerPoint file in C\temp\presentation.pptx that contains on the first slide 2 entries as "<one>" and "<two>" which need to be replaced with "user1" and "user2", then a silent Outlook send mail containing the file with a predefined body and subject. I narrowed it down to COM objects as the Office does not like intrusive open AutoIt functions. I installed OLE/COM Object Viewer to understand how to create the commands but i am still stuck. So far i am trying to user water's code but i suck COM object i was originally trying to modify Dim$oPPT, $oPres$oPPT = ObjCreate("PowerPoint.Application") $oPPT.Visible = True$oPres = $oPPT.Presentations.Read Water's code below (0.1% modified) #include <File.au3> #include "PowerPoint.au3" #include <misc.au3> Global$sFile = "C:\temp\presentation.pptx" Global $sString2Search = "<username>",$sString2Replace = "Password", $iReplaceOnce = 1,$sFullLogFile = "C:\temp\pptxlog.txt" _ProcessPpt($sFile) Func _ProcessPpt($sFile) $oApp = _PPT_PowerPointApp() Local$bChange = False Local $oInterface =$oApp.Presentations Local $oPresentation =$oInterface.Open($sFile, False, False, False) If @error Then _FileWriteLog($sFullLogFile, "E Error " & @error & " opening File " & $sFile) Return SetError(1, 0, 0) EndIf ;it does not even open my file and from here not sure how to read the text and replace it EndFunc ;==>_ProcessPpt • 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.