Reizvoller

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! ) 

https://www.autoitscript.com/wiki/OutlookEX_UDF_-_General

 

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 this post


Link to post
Share on other sites



Should I repost this in this forum thread?

 

 

 

 

Share this post


Link to post
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 (2016-08-18 - Version 1.4.6.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2016-12-04 - Version 1.2.2.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

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 this post


Link to post
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 this post


Link to post
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 (2016-08-18 - Version 1.4.6.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2016-12-04 - Version 1.2.2.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

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 this post


Link to post
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 (2016-08-18 - Version 1.4.6.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2016-12-04 - Version 1.2.2.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 (2016-08-18 - Version 1.4.6.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2016-12-04 - Version 1.2.2.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 :D


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2016-08-18 - Version 1.4.6.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2016-12-04 - Version 1.2.2.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

    • LinkOut
      By LinkOut
      Hi! I wrote an UDF that can simplify the way you can control Telegram Bot with AutoIt. If you don't know what is a Telegram Bot, maybe you should read their official website here. All about this UDF is on my GitHub: what is, how it work, how to use and also a Test.au3 to see the script in action. But... let's talk about this UDF.
      What is: It's an UDF that contain functions to control a Telegram Bot. Send messages, photo, video, stickers, wait for incoming messages and answer to them. How it works: Insert you Token given from BotFather, initialize your bot with _InitBot() function and... you're ready! All functions are commented: You will find a description of what it does, an explanation for every argument that function has need and what it return. This is the test script, that initialize your bot, run all functions and write the return value.
      #include "Telegram UDF.au3" $ChatID = "Your_Chat_ID_For_Test" _InitBot("Bot_ID","Bot_Token") ConsoleWrite("Test _GetUpdates -> " & @TAB & _GetUpdates() & @CRLF) ConsoleWrite("Test _GetMe -> " & @TAB & _GetMe() & @CRLF) ConsoleWrite("Test _SendMsg -> " & @TAB & _SendMsg($ChatID,"Test _SendMsg") & @CRLF) ConsoleWrite("Test _ForwardMsg -> " & @TAB & _ForwardMsg($ChatID,$ChatID,'MsgID') & @CRLF) ConsoleWrite("Test _SendPhoto -> " & @TAB & _SendPhoto($ChatID,"C:\image.jpg","Test _SendPhoto") & @CRLF) ConsoleWrite("Test _SendVideo -> " & @TAB & _SendVideo($ChatID,"C:\video.mp4","Test _SendVideo") & @CRLF) ConsoleWrite("Test _SendAudio -> " & @TAB & _SendAudio($ChatID,"C:\audio.mp3","Test _SendAudio") & @CRLF) ConsoleWrite("Test _SendDocument -> " & @TAB & _SendDocument($ChatID,"C:\document.txt","Test _SendDocument") & @CRLF) ConsoleWrite("Test _SendVoice -> " & @TAB & _SendVoice($ChatID,"C:\voice.ogg","Test _SendVoice") & @CRLF) ConsoleWrite("Test _SendSticker -> " & @TAB & _SendSticker($ChatID,"C:\sticker.webp") & @CRLF) ConsoleWrite("Test _SendLocation -> " & @TAB & _SendLocation($ChatID,"74.808889","-42.275391") & @CRLF) ConsoleWrite("Test _SendContact -> " & @TAB & _SendContact($ChatID,"0123456789","Josh") & @CRLF) ConsoleWrite("Test _SendChatAction -> " & @TAB & _SendChatAction($ChatID,"typing") & @CRLF) ConsoleWrite("Test _GetUserProfilePhotos -> " & @TAB & _GetUserProfilePhotos($ChatID) & @CRLF) ConsoleWrite("Test _GetChat -> " & @TAB & _GetChat($ChatID) & @CRLF) While 1 $msgData = _Polling() _SendMsg($msgData[2],$msgData[3]) WEnd Last part of the script (While cycle) use Polling function to put the script in a wait-state for incoming messages: _Polling() function return an array ($msgData in this case) that contain information about the received message (for example, $msgData[2] is the Chat ID of the user that send the message, important to send a reply. See GitHub page for other info.
      So, finally, here you can find and download the library -> https://github.com/xLinkOut/telegram-udf-autoit <-
      UPDATE: Thanks to @mLipok to added my Telegram UDF on AutoItScript Wiki!  
      UPDATE 2: Functions that send files to Telegram Servers (photos, videos..) don't need anymore cURL executable file. Thanks to @Jos that suggested how to use WinHttp UDF by trancexx.
      If you have question, bug report or anything else just contact me or reply to this Thread Don't forget to follow me on GitHub for future updates. Bye!
    • ur
      By ur
      I wrote a macro for outlook to send an email.
      Till yesterday it worked, don't know why it is not working today
      I am getting below error when I ran the macro.
       

    • WoodGrain
      By WoodGrain
      Hi guys,
      This post was originally going to be a question on how to fix this issue but as I ended up figuring it out I thought I'd post it here for others that have the same issue.
      So you've downloaded and extracted the latest version of the SQLite dll files etc into the same directory as your SQLite script but it's failing at _SQLite_Startup()?
      What you need to do, that I couldn't see anywhere in the documentation, to fix the issue is rename the dll files from (for example) "sqlite3_301500000.dll" to "sqlite3.dll" and "sqlite3_x64_301500000.dll" to "sqlite3_x64.dll".
      Fixed my issues instantly!
      Hope it can help others too.
      Cheers.
    • ur
      By ur
      Through below script I am able to send mail with the Outlook installed in my machine.
       
      But I am getting below prompt whenever I ran this script,by Outlook.
      Can anyone suggest how to suppress this.
      #include <MsgBoxConstants.au3> ; Counting the number of open shell windows Local $oShell = ObjCreate("Outlook.Application") ; Get the Windows Shell Object If IsObj($oShell) Then $Mail = $oShell.CreateItem(0) $Mail.To = "dponnada@erwin.com" $Mail.Subject = "Action" $Mail.Body ="Pay rise please" $Mail.Send() EndIf  

    • GMK
      By GMK
      Attached is a UDF for automating Monarch. This was created for my use at work, but I thought I'd share, in case anyone else can use it.
      Update: Localized variables and commented out unused variables to be used later.
      Update (November 17, 2016): Uploaded newest version, after revisiting and revising error checking. Script-breaking change: Functions start with _Monarch_ now.
       
      Monarch.au3