Jump to content
water

OutlookEX UDF: Example scripts

Recommended Posts

13 minutes ago, water said:

As you didn't specify properties to be returned by the function default properties (Subject,Body,CreationTime,LastModificationTime,Size) are being used.
There are members in your folder where property "Subject" isn't set (denoted by @extended = 1, the property index).

Either specify the properties you are interested in or I need to provide a modified function to ignore such errors.

 

But i change it in this way, and i get the same error: _OL_ItemFind($oOutlook, $Outlook_Folder, $olMail, "", "", "", "EntryID",0)

 

PS:You answered are very fast ;-)

Edited by Clown007_de

Share this post


Link to post
Share on other sites

Is there something special (anything else than mail items etc.) in the folder you are searching?

BTW: The last parameter is wrong. Insert a blank string parameter before the last parameter.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-10-24 - Version 1.4.14.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-11-30 - Version 1.4.0.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (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
Task Scheduler (NEW 2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki

 

Share this post


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

Is there something special (anything else than mail items etc.) in the folder you are searching?

BTW: The last parameter is wrong. Insert a blank string parameter before the last parameter.

Okay i change it in this way: ... , $olMail, "", "", "", "EntryID",""). But the result is the same.

I can't see any other elements in this folder, but how can i test it?

Can i use a filter for only mail objects?

Edited by Clown007_de

Share this post


Link to post
Share on other sites

You could modify function _OL_ItemFind to ignore the error:

; Fill array with the specified properties
$iCounter += 1
If BitAND($iFlags, 4) <> 4 Then
    For $iIndex = 1 To $aReturnProperties[0]
        $aItems[$iCounter][$iIndex - 1] = $oItem.ItemProperties.Item($aReturnProperties[$iIndex]).value
        If @error Then ContinueLoop  ; <== Changed line
        If BitAND($iFlags, 2) = 2 And $iCounter = 1 Then $aItems[0][$iIndex - 1] =  $oItem.ItemProperties.Item($aReturnProperties[$iIndex]).Name
    Next
EndIf

 

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-10-24 - Version 1.4.14.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-11-30 - Version 1.4.0.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (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
Task Scheduler (NEW 2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Glad the problem could be solved :)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-10-24 - Version 1.4.14.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-11-30 - Version 1.4.0.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (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
Task Scheduler (NEW 2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Do you want to add the image as a shortcut to the location of the original file or should the attachment be a copy of the original file plus a link to another URL?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-10-24 - Version 1.4.14.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-11-30 - Version 1.4.0.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (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
Task Scheduler (NEW 2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Create an HTML mail item and enclose the picture into an "<A>" elemnt.
See example _OL_ItemCreate.au3 example 4 for a start.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-10-24 - Version 1.4.14.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-11-30 - Version 1.4.0.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (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
Task Scheduler (NEW 2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
1 minute ago, hevilp said:

I want the image and a link to a website if I click on the image ==> all in the signatur with 

_OL_MaiLSignatureCreate

 

Share this post


Link to post
Share on other sites

Version 1.2.3.0 of the UDF has been released.

Please test before using in production!

For download please see my signature.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-10-24 - Version 1.4.14.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-11-30 - Version 1.4.0.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (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
Task Scheduler (NEW 2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

I've been having a bit of a play around with the UDF and makes life a lot easier to see what is in my (multiple) Outlook mailboxes. Other than the two leading slashes that _OL_ItemFind doesn't like which breaks the convention of the other subroutines, the loops seem to flow easily.

I am trying to list all mail items and the following code is working with everything except RSS items. The actual RSS folder names are being listed, but the subjects for each RSS item within the folder is not

Full code below:

; *****************************************************************************
; Name:         ListAllEmails.au3
; Purpose:      List all mail item subjects in all Outlook mailboxes. Sorted alphabetical by each folder
; Notes:        Will work with multiple mailboxes. Tested OK on Outlook 2016 with POP3, IMAP and Microsoft Exchange mix of mailboxes
;               Do not run as administrator, as Outlook security access levels must be same as this routine for it to work
;               Say, you must be desperate to be looking in here
; Version:      0.9
; Date Written  March 2017
; Last revision April 2, 2017
; Author        AutoIT forum member Confuzzled
; Dependencies  OutlookEx.au3
; Status:       All working except RSS items not displayed
; *****************************************************************************

#include <OutlookEX.au3> ; Using version 1.3.1.0

Global $FileNameListing = @ScriptDir & "\OutlookMailSubjectListing " & @YEAR & "-" & @MON & "-" & @MDAY &  ".txt" ; Give the report file a name

; *****************************************************************************
; Set up reporting file
; *****************************************************************************
$Event_Filehandle = FileOpen($FileNameListing, 2) ;Open file for output, overwrite mode
FileWrite ($Event_Filehandle, "Report generated on " & @YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " on " & @ComputerName & @CRLF) ;Write some header information
FileWrite ($Event_Filehandle, "The computer is running " & @OSVersion &  " " & @OSServicePack & " Build " & @OSBuild & ", Architecture " &  @OSArch & @CRLF) ;Environment running on
FileWrite ($Event_Filehandle, "List of mail item subjects:" & @CRLF & @CRLF)

; *****************************************************************************
; Create Outlook environment by creating an Outlook object
; *****************************************************************************
Global $oOutlook = _OL_Open()
If @error <> 0 Then Exit MsgBox(16, "ListAllEmails", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended)

; *****************************************************************************
; List all accounts available for the current logged on profile
; *****************************************************************************
Global $AccountResult = _OL_AccountGet($oOutlook) ; Get all accounts
If @error <> 0 Then Exit MsgBox(16, "ListAllEmails", "Error getting list of accounts. @error = " & @error & ", @extended = " & @extended)
;_ArrayDisplay($AccountResult, "ListAllEmails - Accounts found", "", 0, "|", "|AccountType|Displayname|SMTPAddress|Username|Account object|AutoDiscoverConnectionMode|ExchangeConnectionMode|ExchangeMailboxServerName|ExchangeMailboxServerVersion")

; *****************************************************************************
; Process each account
; *****************************************************************************
For $AccountIndex = 1 To UBound($AccountResult)-1 ;(array is zero based)
    ; Column 2 contains the mailbox SMTP email address, Column 4 contains the account object
    ; ConsoleWrite("Processing mailbox #" & $AccountIndex & ", Mailbox name is " & $AccountResult[$AccountIndex][2] & @CRLF)

    Global $FolderResult = _OL_FolderTree($oOutlook, $AccountResult[$AccountIndex][1]) ; Find all folders in each account
    If @error <> 0 Then
        ConsoleWrite(" Error " & @error & " - folder not found for mailbox " & $AccountResult[$AccountIndex][2] & @CRLF)
    Else
        FileWrite ($Event_Filehandle, "Processing account: " & $AccountResult[$AccountIndex][2] & @CRLF) ; Writes Account info to console
        ConsoleWrite ("Processing account " & $AccountResult[$AccountIndex][2] & @CRLF) ; Writes Account info
        ;_ArrayDisplay($FolderResult, "FolderTree for mailbox " & $AccountResult[$AccountIndex][2], "", 0, "|", "|RSS Feed|")
        For $FolderIndex = 1 To UBound($FolderResult)-1 ;(array is zero based), the [0] index contains the root name
            ConsoleWrite(" Account index "& $AccountIndex & ", Folder index is " & $FolderIndex & ", Folder name is " & $FolderResult[$FolderIndex] & @CRLF)
            FileWrite ($Event_Filehandle, " Folder: " & $FolderResult[$FolderIndex] & @CRLF & "  Subject:" & @CRLF) ; Writes Folder info

            Global $ItemResult = _OL_ItemFind($oOutlook, StringMid($FolderResult[$FolderIndex],3), $olMail, "", "", "", "Subject,SenderName","[Subject]", 1) ; find all items in specified folder [who is daft person that left the folder name <two leading slashes> in only some of the subroutines - yuk!]
            If @error <> 0 Then
                ConsoleWrite("  ItemFind Error " & @error & " - Extended " & @extended & @CRLF)
            Else
                ;_ArrayDisplay($ItemResult, "ListAllEmails: Item result for " & $FolderResult[$FolderIndex])
                For $MailIndex = 1 To UBound($ItemResult)-1 ;(array is zero based), the [0] index contains the root name
                    ConsoleWrite("  -#Mail #" & $MailIndex & ", Folder #" & $FolderIndex & ", Account #" & $AccountIndex & ", Folder: " & $FolderResult[$FolderIndex] & ", Subject: " & $ItemResult[$MailIndex][0] & ", Sender Name: " & $ItemResult[$MailIndex][1] & @CRLF)
                    FileWrite ($Event_Filehandle, $ItemResult[$MailIndex][0] & @CRLF) ;Write the subject information to the file
                Next
            EndIf
        Next
    EndIf
Next ; Big loop: Big fleas have little fleas upon their backs to bite them, and little fleas have lesser fleas, and so, ad-infinitum. The Siphonaptera, Augustus De Morgan
ConsoleWrite("Finished extracting information. Program will now complete" & @CRLF) ; Let them know it is now finished extracting information

; *****************************************************************************
; Close Outlook environment by closing Outlook object
; *****************************************************************************
_OL_Close($oOutlook)

; *****************************************************************************
; Write ending footer to report file
; *****************************************************************************
FileWrite ($Event_Filehandle, @CRLF & "Report finished on " & @YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC  & @CRLF)
FileClose ($Event_Filehandle)

; *****************************************************************************
; Open report file
; *****************************************************************************
ShellExecute ($FileNameListing,"",@ScriptDir,"", @SW_MAXIMIZE) ; Open the results file for viewing using default OS handler for the file type

; *****************************************************************************
; Program ends  2 Timothy 4:7-8 (KJV)
; *****************************************************************************

#cs
;Extracted from the constants definition file OutlookExConstants.au3
; OlDefaultFolders Enumeration. Specifies the folder type for the current Outlook profile.
; See: http://msdn.microsoft.com/en-us/library/bb208072.aspx
Global Const $olFolderDeletedItems = 3 ; The Deleted Items folder
Global Const $olFolderInbox = 6 ; The Inbox folder
Global Const $olFolderJunk = 23 ; The Junk E-Mail folder
Global Const $olFolderRssFeeds = 25 ; The RSS Feeds folder

; OlItemType Enumeration. Indicates the Outlook Item type.
; See: http://msdn.microsoft.com/en-us/library/bb208104.aspx
Global Const $olAppointmentItem = 1 ; Represents an AppointmentItem
Global Const $olContactItem = 2 ; Represents a ContactItem
Global Const $olDistributionListItem = 7 ; Represents an DistListItem
Global Const $olJournalItem = 4 ; Represents a JournalItem
Global Const $olMailItem = 0 ; Represents a MailItem
Global Const $olNoteItem = 5 ; Represents a NoteItem
Global Const $olPostItem = 6 ; Represents a PostItem
Global Const $olTaskItem = 3 ; Represents a TaskItem

; OlObjectClass Enumeration. Constants representing the different Microsoft Office Outlook object classes.
; See: http://msdn.microsoft.com/en-us/library/bb208118(v=office.12).aspx
Global Const $olAccount = 105 ; Represents an Account object
Global Const $olAccountRuleCondition = 135 ; Represents an AccountRuleCondition object
Global Const $olAccounts = 106 ; Represents an Accounts object
Global Const $olFolder = 2 ; Represents a Folder object
Global Const $olFolders = 15 ; Represents a Folders object
Global Const $olFolderUserProperties = 172 ; Represents a UserDefinedProperties object
Global Const $olFolderUserProperty = 171 ; Represents a UserDefinedProperty object
Global Const $olItemProperties = 98 ; Represents an ItemProperties object
Global Const $olItemProperty = 99 ; Represents an ItemProperty object
Global Const $olItems = 16 ; Represents an Items object
Global Const $olMail = 43 ; Represents a MailItem object
Global Const $olRule = 115 ; Represents a Rule object
Global Const $olRuleAction = 117 ; Represents a RuleAction object
Global Const $olRuleActions = 116 ; Represents a RuleAction object
Global Const $olRuleCondition = 127 ; Represents a RuleCondition object
Global Const $olRuleConditions = 126 ; Represents a RuleConditions object
Global Const $olRules = 114 ; Represents a Rules object
Global Const $olSearch = 77 ; Represents a Search object
Global Const $olSendRuleAction = 119 ; Represents a SendRuleAction object

#ce

Any hints on what constant I should use to list the RSS items as well if the constant $olMail is not appropriate, or are RSS items outside the scope of this UDF?

Share this post


Link to post
Share on other sites

As far as I understand it there is no special RSS item type available. Only the folder type tells you that you are processing a RSS folder. The items seem to be mail items.
Could you access such a RSS item and check the item property?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-10-24 - Version 1.4.14.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-11-30 - Version 1.4.0.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (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
Task Scheduler (NEW 2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

_OL_UserpropertyGet.htm example could probably do with a brush up!  Working on it.

Share this post


Link to post
Share on other sites

_OL_FolderAccess on an existing RSS folder gives: Default item type: 0, StoreID: 0000000038A1-long string-----, EntryID: 00000000D11-shorter string, Folderpath: \\-actual full folder path-

Point me how to get to a RSS item if _OL_ItemFind is not returning any items for which to check the properties ?

Share this post


Link to post
Share on other sites

Confirming that uncommenting the line (62):

_ArrayDisplay($ItemResult, "ListAllEmails: Item result for " & $FolderResult[$FolderIndex])

in my sample code display one row with two columns with values of 0 and 2 respectively for each RSS folder that has RSS items in it.

For each loop in a RSS folder that contains quite a few items, the loop takes a longer time, which tends to infer that _OL_ItemFind is hitting some items and processing them internally, just not spitting out the results.

Edited by Confuzzled

Share this post


Link to post
Share on other sites

On another minor subject, can we have a _OL_TestEnvironmentDelete function as well to clean up independently from _OL_TestEnvironmentCreate?

Share this post


Link to post
Share on other sites

_OL_TestEnvironmentCreate is used to delete the test environment as well.
Run _OL_TestEnvironment.au3 for a GUI version.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-10-24 - Version 1.4.14.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-11-30 - Version 1.4.0.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (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
Task Scheduler (NEW 2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Open an RSS item and then start the following script (untested):

#include <OutlookEX.au3>
Global $oOL = _ OL_Open()
Global $oItem = $oOL.ActiveInspector.CurrentItem
MsgBox(0, "Type", "Type: " & $oItem.Type)

 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-10-24 - Version 1.4.14.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-11-30 - Version 1.4.0.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (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
Task Scheduler (NEW 2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - 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...