Jump to content
MCv

OutlookEX: connecting to different mailboxes

Recommended Posts

Hi,

I'm fairly new to AutoIt, so please forgive me for asking. I have already searched and found a similar topic ( 

but I can't seem to get it working.

I can only connect to the default user/mailbox, but not other mailboxes. I have my.name@company.com and also access to a few generic support mailboxes in the company, xyz@company.com and bla@company.com. Accessing my.name@company.com works fine, but I need access to the inbox from the other mailboxes.

The example au3 for FolderAccess gives an error when I try to use it with, for example, bla@company.com

I have read the wiki https://www.autoitscript.com/wiki/OutlookEX_UDF_-_Folder_Item

Does someone have a working code snippet for this particular problem?

Many thanks.

Share this post


Link to post
Share on other sites

Can you please post the code snippet where you access the folder?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-08-19 - Version 1.4.13.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-07-24 - Version 1.3.6.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (NEW 2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
#include <OutlookEX.au3>

Global $oOutlook = _OL_Open()

$aFolder = _OL_FolderAccess($oOutlook, "bla@company.com")
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_FolderAccess Example Script", "Error accessing the default contacts folder. @error = " & @error)
$aFolder[1].Display
MsgBox(64, "OutlookEX UDF: _OL_FolderAccess Example Script", "Default contacts folder successfully accessed and displayed.")

_OL_Close($oOutlook)

A very short version of your FolderAccess example code. This code gives error 4, if I use \\bla@company.com I get error 1.

Share this post


Link to post
Share on other sites

Forgot to say that if I use "\\bla@company.com", $olFolderInbox) I get error 3.

Share this post


Link to post
Share on other sites
Posted (edited)

Could you please try: _OL_FolderAccess($oOutlook, "\\bla@company.com\", $olFolderInbox)

Edited by water
Parameter 1 was missing - hence the error

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-08-19 - Version 1.4.13.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-07-24 - Version 1.3.6.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (NEW 2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
13 minutes ago, water said:

Could you please try: _OL_FolderAccess("\\bla@company.com\", $olFolderInbox) 

That also gives error 4.

I tried referencing the account by name instead of email address and that seems to do more. It opens up a search (for the correct account!), but not the Inbox / number of emails in the Inbox. Is OutlookEX compatible with Outlook 365?

 

Share this post


Link to post
Share on other sites
3 hours ago, MCv said:

Is OutlookEX compatible with Outlook 365?

Only with the on premise version not the cloud based. Which one do you run?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-08-19 - Version 1.4.13.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-07-24 - Version 1.3.6.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (NEW 2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
51 minutes ago, water said:

Only with the on premise version not the cloud based. Which one do you run?

How can I tell? I'm just an employee :)

Share this post


Link to post
Share on other sites

I only use Office 2016.
So I had a look at Google: https://www.howtogeek.com/354238/whats-the-latest-version-of-microsoft-office/


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-08-19 - Version 1.4.13.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-07-24 - Version 1.3.6.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (NEW 2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites

I have Outlook 365 ProPlus. I don't know what installation method the IT people have chosen though.

Do you have a suggestion/improvement for the referencing by name and not getting the Inbox?

Share this post


Link to post
Share on other sites

The OutlookEX UDF does only support local installations of Outlook.
So I suggest to ask the IT people if there is a local installation.

I had a look at your script and noticed that you do not check for errors after _OL_Open. If there is no local Office installation then you should get an error raised by _OL_Open.
Can you please check?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-08-19 - Version 1.4.13.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-07-24 - Version 1.3.6.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (NEW 2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
#include <OutlookEX.au3>

Global $oOutlook = _OL_Open()
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended)
$aFolder = _OL_FolderAccess("\\bla@company.com\", $olFolderInbox) 
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_FolderAccess Example Script", "Error accessing the default contacts folder. @error = " & @error)
$aFolder[1].Display
MsgBox(64, "OutlookEX UDF: _OL_FolderAccess Example Script", "Default contacts folder successfully accessed and displayed.")

_OL_Close($oOutlook)

Added the error check: no errors on _OL_Open, just the error on _OL_FolderAccess. So I guess it's a local installation. I have another AutoIt/OutlookEX script for the default account and that works fine.

Share this post


Link to post
Share on other sites

Looks good so far. Seems we need to do additional tests. 

Will be back in a few hours. 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-08-19 - Version 1.4.13.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-07-24 - Version 1.3.6.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (NEW 2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
#include <OutlookEX.au3>

Global $oOutlook = _OL_Open()
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended)
$aFolder = _OL_FolderAccess($oOutlook, "ACCOUNT NAME") 
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_FolderAccess Example Script", "Error accessing the default contacts folder. @error = " & @error)
$aFolder[1].Display
MsgBox(64, "OutlookEX UDF: _OL_FolderAccess Example Script", "Default contacts folder successfully accessed and displayed.")

_OL_Close($oOutlook)

This is what my most successful version looks like. This opens an Outlook window that lets you search in the correct mailbox, but doesn't show the Inbox.

Share this post


Link to post
Share on other sites

Btw, adding , $olFolderInbox) to _OL_FolderAccess in the above example doersn't make any difference.

Share this post


Link to post
Share on other sites
Posted (edited)

Well, I opened the code of _OL_FolderAccess, and I don't believe it is possible to use "\\bla@company.com".  Seems to me that you would need to use "\\FisrtName Name" format.  However I tried using it but it doesn't work either for me. (Outlook 2003 here). 

@water The first line of code of the function is highly suspicious. 

If $sFolder = "" = Default Then $sFolder = ""

And the problem seems to come from those 3 lines

Local $oDummy = $oNamespace.CreateRecipient("=" & $aFolders[1]) ; Create Recipient. "=" sets resolve to strict
$oDummy.Resolve ; Resolve
If Not $oDummy.Resolved Then Return SetError(2, 0, "")

I tried some modifs to make it work, unsuccessfully

Edit - Reading MSDN

RecipientName    Required    String    The name of the recipient; it can be a string representing the display name, the alias, or the full SMTP email address of the recipient.

So it should also work with  "\\bla@company.com"

Edited by Nine

Share this post


Link to post
Share on other sites
1 hour ago, Nine said:

Edit - Reading MSDN

RecipientName    Required    String    The name of the recipient; it can be a string representing the display name, the alias, or the full SMTP email address of the recipient.

So it should also work with  "\\bla@company.com"

You are referring to https://docs.microsoft.com/en-us/office/vba/api/outlook.recipients ?

Share this post


Link to post
Share on other sites
4 hours ago, Nine said:

If $sFolder = "" = Default Then $sFolder = ""

That's correct, it's a bug!


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-08-19 - Version 1.4.13.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-07-24 - Version 1.3.6.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (NEW 2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites

Can you please post a screenshot of Outlook after you have manually connected to the other mailbox (all private info can be greyed out)?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-08-19 - Version 1.4.13.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-07-24 - Version 1.3.6.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (NEW 2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
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

×
×
  • Create New...