Jump to content

OutlookEX UDF - Help & Support (IV)


water
 Share

Recommended Posts

Is a bug in the function.

Function fixed:

; #FUNCTION# ====================================================================================================================
; Name ..........: _OL_StoreGet
; Description ...: Returns information about the Stores in the current profile.
; Syntax.........: _OL_StoreGet($oOL)
; Parameters ....: $oOL - Outlook object returned by a preceding call to _OL_Open()
; Return values .: Success - two-dimensional one based array with the following information:
;                  |0  - display name of the Store object
;                  |1  - Constant in the OlExchangeStoreType enumeration that indicates the type of an Exchange store
;                  |2  - Full file path for a Personal Folders File (.pst) or an Offline Folder File (.ost) store
;                  |3  - True if the store is a cached Exchange store
;                  |4  - True if the store is a store for an Outlook data file (Personal Folders File (.pst) or Offline Folder File (.ost))
;                  |5  - True if Instant Search is enabled and operational
;                  |6  - True if the Store is open
;                  |7  - String identifying the Store (StoreID)
;                  |8  - True if the OOF (Out Of Office) is set for this store
;                  |9  - Warning Threshold represented in kilobytes (in KB)
;                  |10 - The limit at which a user can no longer send messages represented in kilobytes (KB)
;                  |11 - The limit where receiving mail is prohibited (also the maximum size of the mailbox) in kilobytes (KB)
;                  |12 - Contains the sum of the sizes of all properties in the mailbox or mailbox root in kilobytes (KB)
;                  |13 - The free space in the mailbox represented in kilobytes (KB)
;                  |14 - The maximum size for a message that a user can send represented in kilobytes (KB)
;                  |15 - True if the Store is Conversation enabled
;                  Failure - Returns "" and sets @error:
;                  |1 - Function is only supported for Outlook 2007 and later
; Author ........: water
; Modified ......:
; Remarks .......: This function only works for Outlook 2007 and later.
;                  It always returns a valid filepath for PST files where function _OL_PSTGet might not (hebrew characters in filename etc.)
;                  +
;                  A store object represents a file on the local computer or a network drive that stores e-mail messages and other items.
;                  If you use an Exchange server, you can have a store on the server, in an Exchange Public folder, or on a local computer
;                  in a Personal Folders File (.pst) or Offline Folder File (.ost).
;                  For a POP3, IMAP, and HTTP e-mail server, a store is a .pst file.
;+
;                  The returned quota information can be represented as -1 (property not set for the store) or -2 (Quota data not available for local storage).
;+
;                  A store supports Conversation view if the store is a POP, IMAP, or PST store, or if it runs Exchange Server >= Exchange Server 2010.
;                  A store also supports Conversation view if the store is running Exchange Server 2007, the version of Outlook is at least Outlook 2010, and Outlook is running in cached mode.
; Related .......:
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _OL_StoreGet($oOL)
    Local $aVersion = StringSplit($oOL.Version, '.'), $iQUOTA_WARNING, $iQUOTA_SEND, $iQUOTA_RECEIVE, $iMESSAGE_SIZE_EXTENDED, $iMAX_SUBMIT_MESSAGE_SIZE
    If Int($aVersion[1]) < 12 Then Return SetError(1, 0, "")
    Local $iIndex = 0, $iStoreType, $oPropertyAccessor
    Local $aStore[$oOL.Session.Stores.Count + 1][16] = [[$oOL.Session.Stores.Count, 16]]
    For $oStore In $oOL.Session.Stores
        $iIndex = $iIndex + 1
        $iStoreType = $oStore.ExchangeStoreType
        $aStore[$iIndex][0] = $oStore.DisplayName
        $aStore[$iIndex][1] = $iStoreType
        $aStore[$iIndex][2] = $oStore.FilePath
        $aStore[$iIndex][3] = $oStore.IsCachedExchange
        $aStore[$iIndex][4] = $oStore.IsDataFileStore
        $aStore[$iIndex][5] = $oStore.IsInstantSearchEnabled
        $aStore[$iIndex][6] = $oStore.IsOpen
        $aStore[$iIndex][7] = $oStore.StoreId
        $oPropertyAccessor = $oStore.PropertyAccessor
        If $iStoreType = $olExchangeMailbox Or $iStoreType = $olPrimaryExchangeMailbox Then
            $aStore[$iIndex][8] = $oPropertyAccessor.GetProperty($sPR_OOF_STAT)
        EndIf
        If $iStoreType = $olExchangePublicFolder Or $iStoreType = $olPrimaryExchangeMailbox Then
            ; Warning Threshold (in KB)
            $iQUOTA_WARNING = $oPropertyAccessor.GetProperty($sPR_QUOTA_WARNING)
            $aStore[$iIndex][9] = (@error = 0) ? $iQUOTA_WARNING : -1
            ; The limit where sending mail is prohibited (in KB)
            $iQUOTA_SEND = $oPropertyAccessor.GetProperty($sPR_QUOTA_SEND)
            $aStore[$iIndex][10] = (@error = 0) ? $iQUOTA_SEND : -1
            ; The limit where receiving mail is prohibited (also the maximum size of the mailbox) (in KB)
            $iQUOTA_RECEIVE = $oPropertyAccessor.GetProperty($sPR_QUOTA_RECEIVE)
            $aStore[$iIndex][11] = (@error = 0) ? $iQUOTA_RECEIVE : -1
            ; Contains the sum of the sizes of all properties in the mailbox or mailbox root (in Bytes)
            $iMESSAGE_SIZE_EXTENDED = $oPropertyAccessor.GetProperty($sPR_MESSAGE_SIZE_EXTENDED) ; Bytes
            If @error Then
                $aStore[$iIndex][12] = -1
                $aStore[$iIndex][13] = -1
            Else
                $aStore[$iIndex][12] = (@error = 0) ? (Round($iMESSAGE_SIZE_EXTENDED / 1024)) : -1
                $aStore[$iIndex][13] = Round($aStore[$iIndex][11] - $aStore[$iIndex][12])
            EndIf
            ; The maximum size for a message that a user can send (in KB)
            $iMAX_SUBMIT_MESSAGE_SIZE = $oPropertyAccessor.GetProperty($sPR_MAX_SUBMIT_MESSAGE_SIZE)
            $aStore[$iIndex][14] = (@error = 0) ? $iMAX_SUBMIT_MESSAGE_SIZE : -1
        Else
            ; Quota data not available for local storage
            $aStore[$iIndex][9] = -2
            $aStore[$iIndex][10] = -2
            $aStore[$iIndex][11] = -2
            $aStore[$iIndex][12] = -2
            $aStore[$iIndex][13] = -2
            $aStore[$iIndex][14] = -2
        EndIf
        $aStore[$iIndex][15] = $oStore.IsConversationEnabled
    Next
    Return $aStore
EndFunc   ;==>_OL_StoreGet

 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Thank you. It's working.

image.png.5f03f37b11e8fb07be2383ce6823aa1f.png

Just added those constants to OutlookExConstants.au3 file

Global Const $sPR_OOF_STAT="http://schemas.microsoft.com/mapi/proptag/0x661D000B"
Global Const $sPR_QUOTA_WARNING="http://schemas.microsoft.com/mapi/proptag/0x341A0003"
Global Const $sPR_QUOTA_SEND="http://schemas.microsoft.com/mapi/proptag/0x341B0003"
Global Const $sPR_QUOTA_RECEIVE="http://schemas.microsoft.com/mapi/proptag/0x341C0003"
Global Const $sPR_MESSAGE_SIZE_EXTENDED="http://schemas.microsoft.com/mapi/proptag/0x0E080014"
Global Const $sPR_MAX_SUBMIT_MESSAGE_SIZE="http://schemas.microsoft.com/mapi/proptag/0x666d0003"

The error is still appearing in Console.

(817) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
$aConversations[$iRowIndex][0] = $oRow(1)
^ ERROR

 

Link to comment
Share on other sites

Seems you are using an older version of the OutlookEX UDF. The UDF now consists of two files:

  • OutlookEX_Base.au3: Constants and basic functions
  • OutlookEX.au3: item related functions
  • OutlookEX_GUI: GUI related functions

The mentioned constants have already been added to OutlookEX_Base. OutlookExConstants.au3 is no longer needed.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

2 minutes ago, water said:

Seems you are using an older version of the OutlookEX UDF. The UDF now consists of two files:

  • OutlookEX_Base.au3: Constants and basic functions
  • OutlookEX.au3: item related functions
  • OutlookEX_GUI: GUI related functions

The mentioned constants have already been added to OutlookEX_Base. OutlookExConstants.au3 is no longer needed.

Yes just noted that, later I will download newer version.

Thanks

Link to comment
Share on other sites

Hey @water

I need some advice. I have looked at this

https://www.autoitscript.com/wiki/OutlookTools#OLT_Export

and https://docs.microsoft.com/en-us/previous-versions/office/developer/office-2007/aa338197(v=office.12)?redirectedfrom=MSDN#creating-custom-task-panes-as-com-add-ins

I don't want a script to search Outlook. 

What I do want is the ability to create a button on the Outlook bar and after the user selects an item (can be calendar, email etc) when clicking the button something should happen.

This of the Attach or Send buttons that already exist. I want to be able to create a custom button.

This first step is to create a COM object that creates a button in Outlook? 

Is there an example of this somewhere?

If you have a moment please?

Skysnake

Skysnake

Why is the snake in the sky?

Link to comment
Share on other sites

I have never worked with such things. So there are no readily available examples.

From the link you posted I see that it is made for Office 2007. That's quite old and IIRC Microsoft has changed the way to modify the GUI.

A quick search returned results like this one: https://www.howto-outlook.com/howto/macrobutton.htm

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

@water me again :)

Global $oOL = _OL_Open()
Global $oTemp = ObjEvent($oOL, "oOL_") ; Create the application-level event handler 
While 1
    Sleep(10)
WEnd
Func oOL_NewMailEx($sEntryIDs)
    Local $iItemCount, $oItem
    Local $aEntryIDs = StringSplit($sEntryIDs, ",", $STR_NOCOUNT) ; multiple EntryIDs are separated by ,
    $iItemCount = UBound($aEntryIDs)
    ConsoleWrite("OutlookEX UDF Example Script - " & ($iItemCount = 1 ? "new item has" : "new items have") & " arrived!" & @CRLF & @CRLF)
    For $i = 0 To $iItemCount - 1
        $oItem = $oOL.Session.GetItemFromID($aEntryIDs[$i], Default) ; Translate the EntryID string to the item object
        ConsoleWrite("From:    " & $oItem.SenderName & @CRLF & "Subject: " & $oItem.Subject & @CRLF & "Class:   " & $oItem.Class & " (43=Mail, 53=MeetingRequest ...)" & @CRLF)
    Next
EndFunc

From here https://www.autoitscript.com/wiki/OutlookEX_UDF_-_General#Events

This little script is brilliant. :)

 

But, I don't understand how it works?

I don't see a function call? So what actually triggers that function to work? I think there is something about the way AutoIt works, that I do not understand.  

 

 

Skysnake

Why is the snake in the sky?

Link to comment
Share on other sites

ObjEvent tells Outlook to call a function named "oOL_" plus the name of the triggered event.

Means: When the NewMailEx event gets triggered Outlook calls function "oOL_NewMaiLEventEx".

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

I made a toy. I think the ArrayDisplay should be updated to _DebugArrayDisplay, but see this

; updated 2021.03.23
; Author Skysnake
; Purpose of this script is only to illustrate various OutlookEX UDF capabilities

#include <OutlookEX.au3>
#include <Debug.au3>
#include <GUIConstantsEx.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

; *****************************************************************************
; Create test environment
; *****************************************************************************
Global $oOutlook = _OL_Open()
If @error <> 0 Then Exit MsgBox(16, "Outlook", "Outlook needs to open before you start this script. Please start Outlook first." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

Local $OL_Default_CurrentUser

Local $hGUI = GUICreate("Show various OutlookEX capabilities", 600, 400)
Local $aResult

Local $cmbFrom = GUICtrlCreateCombo("", 8, 8, 200, 20)
GUICtrlCreateLabel("'From' available SENDER accounts", 210, 8, 200, 20)
Local $cmbTo = GUICtrlCreateCombo("", 8, 38, 200, 20)
GUICtrlCreateLabel("'To' available destinations from WAB ", 210, 38, 200, 20)
Local $btnAttach = GUICtrlCreateButton("Attach", 8, 68, 200, 20)
GUICtrlCreateLabel("'Attachments' filepath for attachment", 210, 68, 200, 20)
Local $cmbSignature = GUICtrlCreateCombo("", 8, 98, 200, 20)
GUICtrlCreateLabel("'Signatures' available Signatures", 210, 98, 200, 20)


; build a message
Local $inputOL_From = GUICtrlCreateInput("", 8, 140, 200, 19)
Local $inputOL_To = GUICtrlCreateInput("", 8, 160, 200, 19)
Local $inputOL_Attach = GUICtrlCreateInput("", 8, 180, 200, 19)
Local $inputOL_Sign = GUICtrlCreateInput("", 8, 200, 200, 19)
Local $inputOL_Body = GUICtrlCreateInput("Body", 8, 220, 200, 19)




; populate each selector
; https://docs.microsoft.com/en-us/office/vba/api/outlook.namespace.currentuser
$OL_Default_CurrentUser = $oOutlook.GetNameSpace("MAPI" ).CurrentUser.Name ; returns The Sky Snake
;$OL_Default_CurrentUser = $oOutlook.GetNameSpace("MAPI" ).CurrentUser.EntryID ; returns 00000000812B1FA4BEA310199D6E00DD010F5402000000804300610072006C00200048006F006C006C006900640061007900000053004D005400500000006300610072006C00400077006F006E006400650072006C0061006E0064002E0063006F002E007A0061000000
;$OL_Default_CurrentUser = $oOutlook.GetNameSpace("MAPI" ).CurrentUser.Class ; returns 4 ?
;$OL_Default_CurrentUser = $oOutlook.GetNameSpace("MAPI" ).CurrentUser.Index ; returns 0
;$OL_Default_CurrentUser = $oOutlook.GetNameSpace("MAPI" ).CurrentUser.PropertyAccessor ; returns nothing
;$OL_Default_CurrentUser = $oOutlook.GetNameSpace("MAPI" ).CurrentUser.Resolved ; returns True
ConsoleWrite("$OL_Default_CurrentUser " & $OL_Default_CurrentUser & @CRLF)

$aAccountInProfile = _OL_AccountGet($oOutlook)
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_AccountGet Example Script", "Error getting list of accounts for the current profile. @error = " & @error & ", @extended = " & @extended)
_DebugArrayDisplay($aAccountInProfile, "OutlookEX UDF: _OL_AccountGet Example Script", "", 0, "|", "|AccountType|Displayname|SMTPAddress|Username|Account object|AutoDiscoverConnectionMode|ExchangeConnectionMode|ExchangeMailboxServerName|ExchangeMailboxServerVersion")
For $s = 1 To UBound($aAccountInProfile) - 1
    GUICtrlSetData($cmbFrom, $aAccountInProfile[$s][1] & "|")
    ConsoleWrite("$aAccountInProfile[$s][1] " & $s & " " & $aAccountInProfile[$s][1] & @CRLF)
Next

Local $aSignatures = _OL_MailSignatureGet()
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_MailSignatureGet Example Script", "Error accessing mail signatures. @error = " & @error & ", @extended: " & @extended)
_DebugArrayDisplay($aSignatures, "OutlookEX UDF: All email signatures for the current mail account", "", 0, "|", "Name|Used for new messages?|Used for reply messages?")
For $s = 1 To UBound($aSignatures) - 1
    GUICtrlSetData($cmbSignature, $aSignatures[$s][0] & "|")
    ConsoleWrite("$aSignatures[$s][0] " & $s & " " & $aSignatures[$s][0] & @CRLF)
Next



Local $btnSendMail = GUICtrlCreateButton("Send Mail", 500, 370, 70, 20)

; Display the child GUI.
GUISetState(@SW_SHOW)

; Loop until the user exits.
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop

        Case $cmbFrom
            GUICtrlSetData($inputOL_From, GUICtrlRead($cmbFrom))

        Case $cmbSignature
            GUICtrlSetData($inputOL_Sign, GUICtrlRead($cmbSignature))

        Case $btnAttach
            ; Create a constant variable in Local scope of the message to display in FileOpenDialog.
            Local $sMessage = "Hold down Ctrl or Shift to choose multiple files."

            ; Display an open dialog to select a list of file(s).
            Local $sFileOpenDialog = FileOpenDialog($sMessage, @WindowsDir & "\", "Images (*.jpg;*.bmp)|Videos (*.avi;*.mpg)", $FD_FILEMUSTEXIST + $FD_MULTISELECT)
            If @error Then
                ; Display the error message.
                MsgBox($MB_SYSTEMMODAL, "", "No file(s) were selected.")

                ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder.
                FileChangeDir(@ScriptDir)
            Else
                ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder.
                FileChangeDir(@ScriptDir)

                ; Replace instances of "|" with @CRLF in the string returned by FileOpenDialog.
                $sFileOpenDialog = StringReplace($sFileOpenDialog, "|", ",")

                ; Display the list of selected files.
                MsgBox($MB_SYSTEMMODAL, "", "You chose the following files:" & @CRLF & $sFileOpenDialog)
            EndIf
            GUICtrlSetData($inputOL_Attach, $sFileOpenDialog)



        Case $btnSendMail
            ;$Result = _OL_ItemSend($oOutlook, $aOL_Item[1][0])
            If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemSend Example Script", "Error sending mail from folder 'Outlook-UDF-Test\SourceFolder\Mail'. @error = " & @error)

            MsgBox(64, "OutlookEX UDF: _OL_ItemSend Example Script", "Mail successfully sent!")


        Case Else
            ;loop

    EndSwitch
WEnd




; Delete the previous GUIs and all controls.
GUIDelete($hGUI)








_OL_Close($oOutlook)

sample.png.9b7ebb0a2144e477c05f7a2627c1fd5b.png

 

; $aAccountInProfile = _OL_AccountGet($oOutlook) returns this

Row  |Col 0|Col 1               |Col 2               |Col 3        |Col 4|Col 5|Col 6|Col 7|Col 8
Row 0|10   |9                   |                    |             |     |     |     |     |
Row 1|2    |skysnake@example.com|skysnake@example.com|The Sky Snake|     |0    |0    |     |

; challenge is to match this and extract email -------------^^^^^^

; script returns

$OL_Default_CurrentUser = $oOutlook.GetNameSpace("MAPI" ).CurrentUser.Name ; returns The Sky Snake

 

 

 

 

Edited by Skysnake

Skysnake

Why is the snake in the sky?

Link to comment
Share on other sites

I wanted to write more in that message but Chrome doesn't want to.

The next phase is to send an email message with those values.

Typically NOT the wrapper, but build the message using those values. I'll update it soon.

BUT, I have never managed to connect the From text selection to the actual Outlook account. --> Advice on this please?

Skysnake

 

Skysnake

Why is the snake in the sky?

Link to comment
Share on other sites

$oOutlook.GetNameSpace("MAPI" ).CurrentUser

returns the display name of the currently logged-on user.
https://docs.microsoft.com/en-us/office/vba/api/outlook.namespace.currentuser

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

I'm having trouble querying my outlook inbox for emails.

#include <OutlookEX.au3>
#include <Array.au3>

Global $oOutlook = _OL_Open()
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended)
$aInboxEmails = _OL_ItemFind($oOutlook, "*\Inbox", $olMail, "[UnRead]=True", "", "", "Subject,Body,@FolderObject,@ItemObject", "", 2)
If @error Then MsgBox(48, "OutlookEX UDF: _OL_ItemFind Example Script", "Could not find email. @error = " & @error & ", @extended: " & @extended)

_ArrayDisplay($aInboxEmails)

I've tried several different methods, but no luck.  Any Suggestions?  I get the following error.

image.png.f78c1dc4a4ae8648275da3f66dba49c7.png

 

AutoIt v3.3.14.5
OutlookEX 1.6.3.1
Outlook 365
Windows 10 Enterprise (1909) x64

Edited by tczbu
Link to comment
Share on other sites

I just ran your example code and it works fine - when there are unread mails or not.
Can you please add

_OL_ErrorNotify(2)

after _OL_Open?
So we get more detailed error information.

 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Do you run the on premise or the cloud version of Outlook?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

I feel silly, but I'm not sure exactly what you mean, or what you're asking.

Outlook is installed on my system.   Does that answer your question?  If not, can you tell me how to check if I run on premise or the cloud version of Outlook?

Thanks for the help!

Link to comment
Share on other sites

Yes, your reply answers my question.

  1. Could you please run the following modified version of your script?
    The error you posted lets me think that there is a problem with one of the properties you would like to get returned.
  2. Could you please filter by hand all unread items in your inbox and make sure they are of the same class? IIRC mails and receipts have the same class but a receipt does not have all properties a mail item has. This could cause the problem.
#include <OutlookEX.au3>
#include <Array.au3>

Global $oOutlook = _OL_Open()
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended)
$aInboxEmails = _OL_ItemFind($oOutlook, "*\Inbox", $olMail, "[UnRead]=True", "", "", "EntryID", "", 2)
If @error Then MsgBox(48, "OutlookEX UDF: _OL_ItemFind Example Script", "Could not find email. @error = " & @error & ", @extended: " & @extended)

_ArrayDisplay($aInboxEmails)


 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

I ran your modified code, and get the same result, but I found the issue.  It had to do with a message that was a recall request.

I could run the code against other folders...just not my inbox.  When I removed the bulk of my emails from my inbox, it was successful.

I narrowed it down to a message that was a "recall request".  I'm not sure if it was stuck, or what.  It had a strikethrough line through the message.  When I clicked on it to view it, it disappeared (now I cant find it).  But the script is working fine now.  I tried to reproduce by creating my own recall request...but wasn't able to reproduce it.  So I don't know exactly what caused it...other than...it was a "recall request" message causing it.

Thanks for the help!

 

 

 

Link to comment
Share on other sites

Great!

_OL_ItemFind checks just the first found item for correct properties (means that the item provides all requested properties). If this check is successfull the script could still crash because an item with the same objectclass could not provide all requested properties.
This seems to be the case for the recall request.

I could add a new flag to _OL_ItemFind to ignore such errors. "N/A" (not available) could be returned to mark such properties.
What do you think?
 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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
 Share

×
×
  • Create New...