Sign in to follow this  
Followers 0
PhillipWoodson

Public Folder Items

21 posts in this topic

I am trying to write a script to access a public folder in outlook and open an item and execute it. I am using the OutlookEX UDF. I can't for the life of me figure out how to make it work. Do you have any examples showing how to use the _OL_FolderAccess and _OL_ItemFind functions. Also once i find the item thats in the folder I want to open it and execute a button that runs an export process on this page. I am a newbie to this and would greatly appreciate a working example.

Thanks.

P

Share this post


Link to post
Share on other sites



Use

$oOutlook = _OL_Open()
$aFolder = _OL_FolderAccess($oOutlook, "rootfolder\subfolder\...\subfolder")
to access the public folder.

Remember that _OL_FolderAccess returns an array so use

$aResult = _OL_ItemFind($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
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Thank you for the code example, that helped. Once i have the Item in the list what command would i use to open the item? $aResult.Open ?

Thanks

Share this post


Link to post
Share on other sites

With "to open the item" do you mean to display the item or do you want to access the properties of the item by your script?


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
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

I want to open the item and press a button on it to execute it.

Share this post


Link to post
Share on other sites

"The item" is it an Outlook "default" item like appointment or mail or a user defined form or something similar?


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
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Its a mail item that has code behind it and button on the front. When executed it performs an export of Data using an odbc driver. The item stays in the folder and gets executed manually when needed.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

This should display the item:

#include <OutlookEx.au3>
$oOutlook = _OL_Open()
$aFolder = _OL_FolderAccess($oOutlook, "rootfoldersubfolder...subfolder")
$aResult = _OL_ItemFind($oOutlook, $aFolder[1], $olMailItem, "[Subject]='Test'", "", "", "EntryID")
_OL_ItemDisplay($oOutlook, $aResult[1][0])

Displays the first item found with a subject of "Test"

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
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

This is the error i get.

(52) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

_OL_ItemDisplay($oOutlook, $aItems[1][0])

_OL_ItemDisplay($oOutlook, ^ ERROR

Here is my code.

$aFolders = _OL_FolderAccess($oOutlook, "Public FoldersAll Public FoldersIT HELP DESKService RequestHelp DeskReports")

$aItems = _OL_ItemFind($oOutlook, $aFolders[1], $olMailItem, "[subject]='Export Utility'","","","EntryID")

_OL_ItemDisplay($oOutlook, $aItems[1][0])

_OL_Close($oOutlook)

Any help would be appreciated.

Share this post


Link to post
Share on other sites

Could you please try this code with extended error checking?

#include <OutlookEx.au3>
$oOutlook = _OL_Open()
If @error Then Exit MsgBox(16, $sTitle, "Error returned by _OL_Open: " & @error & ", @extended: " & @extended)
$aFolders = _OL_FolderAccess($oOutlook, "Public FoldersAll Public FoldersIT HELP DESKService RequestHelp DeskReports")
If @error Then
    MsgBox(16, $sTitle, "Error returned by _OL_FolderAccess: " & @error & ", @extended: " & @extended)
Else
    $aItems = _OL_ItemFind($oOutlook, $aFolders[1], $olMailItem, "[Subject]='Export Utility'", "", "", "EntryID")
    If @error Then
        MsgBox(16, $sTitle, "Error returned by _OL_ItemFind: " & @error & ", @extended: " & @extended)
    ElseIf $aItems[0][0] = 0 Then
        MsgBox(16, $sTitle, "No mail items found!")
    Else
        _OL_ItemDisplay($oOutlook, $aItems[1][0])
    EndIf
EndIf
_OL_Close($oOutlook)

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
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

It returned the message No Mail Items Found. So its a different item type.

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Then put a ";" in front of line

If $oOL_Item.Class <> $iOL_ObjectClass Then ContinueLoop
in function _OL_ItemFind so the class is ignored.

And then please run this modified version

#include <OutlookEx.au3>
$oOutlook = _OL_Open()
If @error Then Exit MsgBox(16, $sTitle, "Error returned by _OL_Open: " & @error & ", @extended: " & @extended)
$aFolders = _OL_FolderAccess($oOutlook, "Public FoldersAll Public FoldersIT HELP DESKService RequestHelp DeskReports")
If @error Then
    MsgBox(16, $sTitle, "Error returned by _OL_FolderAccess: " & @error & ", @extended: " & @extended)
Else
    $aItems = _OL_ItemFind($oOutlook, $aFolders[1], $olMailItem, "[Subject]='Export Utility'", "", "", "EntryID,Class")
    If @error Then
        MsgBox(16, $sTitle, "Error returned by _OL_ItemFind: " & @error & ", @extended: " & @extended)
    ElseIf $aItems[0][0] = 0 Then
        MsgBox(16, $sTitle, "No mail items found!")
    Else
        _ArrayDisplay($aItems)
        _OL_ItemDisplay($oOutlook, $aItems[1][0])
    EndIf
EndIf
_OL_Close($oOutlook)

We can then check the displayed array.

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
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

I am not sure i understand what you are telling me to do. This line is not in the code you provided. Do i need to add this code ?

If $oOL_Item.Class <> $iOL_ObjectClass Then ContinueLoop

Share this post


Link to post
Share on other sites

This line is in the UDF function _OL_ItemFind.

It checks for the specified class and if equal the item is ignored.


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
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

That worked. I got an error message stating that the export utility can only be opened by a named seat but thats a lot farther along.

Share this post


Link to post
Share on other sites

Can you tell me what you get in the _ArrayDisplay? First column is the EntryID of the item, and the second is the objectclass. That's the interesting value.


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
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Row | Col 0 | Col 1

[0] | 1 | 2

[1] | 000000001A447390AA6611CD9BC800AA002FC45A0900834E9F82BA4B124688452249785E1F8A0246FD8B67150000834E9F82BA4B124688452249785E1F8A0246FD8C54040000 | 43

Share this post


Link to post
Share on other sites

I see. We used the wrong constant: It should be $olMail not $olMailitem


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
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

I changed it to the $olMail and still received the error message "Export utility can only be opened by a named seat". For some reason its not pickup up my mail profile for opening the item.

Share this post


Link to post
Share on other sites

You manually click on the button and execute the code? The AutoIt script doesn't do anything you wouldn't do yourself. Does it work when you do it yourself?

What does the code in the mail item do?


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
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

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
Sign in to follow this  
Followers 0