Jump to content

Recommended Posts

Posted (edited)

The Outlook UDF creates some additional folders etc. when testing but doesn't remove any of your stores or folders.

Is your mailbox on an Exchange server?

Edited by water

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

 

Posted

You could run the _OL_TestEnvironment.au3 and delete the test environment.

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

 

  • 2 weeks later...
Posted

First try for an extended Outlook search function. Functionality should be similar to Ctrl+Shift+F in Outlook.

Docu is still incomplete but the examples work.

The examples search through the inbox for the content described in variables $sStringx. Change them to your liking.

What do you think? Does it work for you? Anything missing? ...

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

 

Posted

Version 0.7.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 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

 

Posted (edited)

Hi there water,

Let me first point out, like many already did, that your work here so far is tremendously appreciated.

Regarding this UDF, it looks really good and with a solid base, but the documentation isn't helping me as much as the "standard" AutoIt documentation usually does. The provided examples also don't go very far as to teaching me how to use the functions to my liking.

I'm not familiar with the Outlook COM, so I've been trying to make it work through trial and error. But still no luck.

EDIT: Our company uses Exchange 2003 + Outlook 2003

For instance, in this case regarding only mail item folders:

1. How does one get the list of possible folders? Some of our users have more than one user's folder in their outlook.

2. How is the path composed? For now, all I know is "" and "*" for the current user's folder. I could use FirstName but there's more than one user with the same first name in my organization, and I wish there would be an accurate way, like using the username or the user's SMTP address. Also I won't know what user folders a certain user will have in their Outlook...?

3. When finding items, the returned array has several possible columns, but which columns are those? "To,Subject,Body" works, but "EntryID,CreationTime,Sendername,To,Subject,Body" only returns a single-row array: [0,6].

4. The only search filters that are working for me are "" and "[unRead] = True". For example, "[start]='2012-01-01 08:00' And [End]='2012-04-04 10:00'" returns the same single-row array: [0,3]. I also have no idea what filters are actually possible; the content on the provided link (M$) is somewhat superficial and lacks examples.

EDIT2: In most of the examples, when I change a parameter and it doesn't return an actual error, the result becomes this single-row array.

My goal here would be integrating mail flow with a database, where the user could choose a mail item directly from Outlook, or from the last 10 mail items, and the whole message + attachments could be copied / stored in the database. Is such a thing possible (copying or saving the whole .msg file in a temporary location)?

DB integration isn't an issue here, just the accessing Outlook mail items part.

The way I see it, if the user couldn't just select the item in Outlook and tell AutoIt "use the currently selected item", then the ideal would be having the possibility of listing the last mail items from each available folder.

I hope I clarified the issues at hand.

I'm really looking forward to using this UDF - once I understand how it works ;)

Thanks in advance for your time.

Edited by footswitch
Posted

1. How does one get the list of possible folders? Some of our users have more than one user's folder in their outlook.

Every function in the UDF comes with a help file (html). There you can find a description of every parameter. If the parameter is an enumeration of Outlook values you find the enumeration name in the help file. The enumeration can be found in the file "OutlookExConstants.au3". A link to the details for this enumeration on MSDN can be found there as well.

Example:

Function _OL_FolderAccess takes an enumeration as parameter $iOL_FolderType. The docu referres to the OlDefaultFolders enumeration. This is described in the "OutlookExConstants.au3" file as

; OlDefaultFolders Enumeration. Specifies the folder type for the current Outlook profile.
; See: http://msdn.microsoft.com/en-us/library/bb208072.aspx
Global Const $olFolderCalendar = 9 ; Calendar folder
Global Const $olFolderContacts = 10 ; The Contacts folder
Global Const $olFolderDeletedItems = 3 ; The Deleted Items folder
Global Const $olFolderDrafts = 16 ; The Drafts folder
Global Const $olFolderInbox = 6 ; The Inbox folder
Global Const $olFolderJournal = 11 ; The Journal folder
Global Const $olFolderJunk = 23 ; The Junk E-Mail folder
Global Const $olFolderNotes = 12 ; The Notes folder
Global Const $olFolderOutbox = 4 ; The Outbox folder
Global Const $olFolderSentMail = 5 ; The Sent Mail folder
Global Const $olFolderTasks = 13 ; The Tasks folder
Global Const $olFolderToDo = 28 ; The To Do folder
Global Const $olFolderRssFeeds = 25 ; The RSS Feeds folder

Section "See:" points you to MSDN

2. How is the path composed?

Please check the help file for function _OL_FolderAccess or the Wiki

Also I won't know what user folders a certain user will have in their Outlook...?

Access the users mailbox and then run function _OL_FolderTree.

3. When finding items, the returned array has several possible columns, but which columns are those? "To,Subject,Body" works, but "EntryID,CreationTime,Sendername,To,Subject,Body" only returns a single-row array: [0,6].

The valid properties depend on the item type. A mail item is different compared to a contact item. You have to check MSDN docu.

Example: Mail item properties can be found here (Outlook 2007).

4. The only search filters that are working for me are "" and "[unRead] = True". For example, "[start]='2012-01-01 08:00' And [End]='2012-04-04 10:00'" returns the same single-row array: [0,3]. I also have no idea what filters are actually possible; the content on the provided link (M$) is somewhat superficial and lacks examples.

Searching in Outlook is quite complex. Searching for dates is even more complex. It depends on the date/time format of your country. I would use ">" and "<" to compare date/time so you can easily get all mails in a time frame.

My goal here would be integrating mail flow with a database, where the user could choose a mail item directly from Outlook, or from the last 10 mail items, and the whole message + attachments could be copied / stored in the database. Is such a thing possible (copying or saving the whole .msg file in a temporary location)?

Sure. To save a mail item use function _OL_ItemSave.

Everything you want to do should be possible with the UDF.

I suggest you start coding, post questions if a problem arises and I will do my very best to solve them.

N.B.: A very good source to understand this UDF is the Wiki (still work in progress).

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

 

Posted

water,

Thank you for taking the time to enlighten me.

Regarding 1. and 2., I think I wasn't clear enough. What I mean is:

I have a user which has access to more than one user's folders.

But I don't know which user's folders he has added to his Outlook application.

What I wanted was to somehow "mimic" the Outlook aspect so the user would intuitively navigate through the folder tree to select the desired item.

Anyway, I tried to discover what _OL_FolderTree() could do to help:

Global $oOutlook = _OL_Open()
Global $aFolder = _OL_FolderAccess($oOutlook, "*", $olFolderInbox)
; ok, no error
Global $aFolderDisplay = _OL_FolderTree($oOutlook, $aFolder[1])
; error 1, extended 0

So yeah, I don't get it. Sorry :/

Example: Mail item properties can be found here (Outlook 2007).

Thank you for this.

I would post some code, but it's like I'm saying, I can't do anything with the UDF yet...

I forgot to mention that most of the examples don't work because the creation of the test environment either fails or isn't completing properly.

Posted (edited)

Ok, for example: search for yesterday's mail flow (default mail folder and subfolders)

#include <OutlookEX.au3>
Global $oOutlook = _OL_Open(True)
Global $aFolder = _OL_FolderAccess($oOutlook, "*", $olFolderInbox)
Global $aItems = _OL_ItemFind($oOutlook, $aFolder[1], $olMail, '@SQL="urn:schemas:httpmail:datereceived" > ''' & _DateAdd("D", -1, _NowCalcDate()) & ''' AND "urn:schemas:httpmail:datereceived" < ''' & _NowCalcDate() & '''', "", "", "EntryID, SenderName, SenderEmailAddress, ReceivedTime, To, Subject, Body", "", 1)
If IsArray($aItems) Then
_ArrayDisplay($aItems, "Yesterday's mail")
Else
MsgBox(48, "Error", "Could not find yesterday's mail. @error = " & @error & ", @extended: " & @extended)
EndIf

EDIT: Please note that usually dates in SQL are "YYYY-MM-DD" but Outlook seems to accept "YYYY/MM/DD", which is the direct output of _NowCalcDate().

How to do this for just one folder? (non-recursive)

If I remove the last two parameters from _OL_ItemFind(), the result is a single-row array.

Edited by footswitch
Posted

Regarding 1. and 2., I think I wasn't clear enough. What I mean is:

I have a user which has access to more than one user's folders.

But I don't know which user's folders he has added to his Outlook application.

The user not only accesses the folders of another user but the folders in anothers users store. To get a list of all accessed stores (Exchange, PST etc.) run _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

 

Posted

To get a list of all accessed stores (Exchange, PST etc.) run _OL_StoreGet.

Only supported for Outlook 2007 and later ;)

Seems like some of my problems are related to the stone age Outlook.

I'm having a look at what my options are, in matters of letting the user select the intended item, and then use that directly.

Posted

Global $oOutlook = _OL_Open()
Global $aFolder = _OL_FolderAccess($oOutlook, "*", $olFolderInbox)
; ok, no error
Global $aFolderDisplay = _OL_FolderTree($oOutlook, $aFolder[1])
; error 1, extended 0
You found a bug!

You can pass the folder to start listing the tree as a string or as an object (as you did). Unfortunately the test for an empty string is at the wrong place so always returns an error even if you pass an object.

Bug will be fixed in the next version (or a workaround can be provided if you need it right now).

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

 

Posted

Only supported for Outlook 2007 and later ;)

Could you please give function _OL_AccountGet a try?

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

 

Posted (edited)

Could you please give function _OL_AccountGet a try?

Same return @error = 1, @extended = 0.

Your help file mentions this.

EDIT: I did bypass the version check in _OL_AccountGet(), and indeed it does not work. LOL talk about trusting the fellow user, eh?

Edited by footswitch
Posted

Just found an old machine that uses Outlook 2002. I will give it a try.

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

 

Posted

Could you please try this code? It should list all the accessed mailboxes.

#include <OutlookEX.au3>

Global $oOutlook = _OL_Open()
$oOL_Namespace = $oOutlook.GetNamespace("MAPI")
For $oFolder In $oOL_Namespace.Folders
    ConsoleWrite($oFolder.Name & @CRLF)
Next

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

 

Posted (edited)

Example: get the selected item and save it in the specified folder.

EDIT: NOTE: The third parameter of _OL_ItemSave(), which is the StoreID, when set to Default works for the selected item, even if it's not in your own store.

; code adapted from: http://support.microsoft.com/kb/240935
#include <OutlookEX.au3>

Global $oOutlook = _OL_Open()

Global $oExp = $oOutlook.ActiveExplorer
Global $oSel = $oExp.Selection

For $i = 1 To $oSel.Count               ; Loop through all the currently .selected items
    Global $oItem = $oSel.Item($i)      ; Get a selected item.
    __DisplayInfo($oItem)               ; Display information about it.
Next

_OL_ItemSave($oOutlook, $oItem.EntryID, Default, "C:temptest.msg", $olMSG, 3)
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemSave Example Script", "Error saving mail item to C:tempOutlook-UDF-TestDir2. @error = " & @error & ", @extended = " & @extended)
MsgBox(64, "OutlookEX UDF: _OL_ItemSave Example Script", "Example 2: Item successfully saved!")

Func __DisplayInfo(ByRef $oItem)
    Switch $oItem.Class
        Case $olMail
            ConsoleWrite("+> it's a mail item!"&@CRLF)
    EndSwitch

    Switch $oItem.MessageClass
        Case "IPM.Appointment"
            MsgBox(0,"Appointment",$oItem.Subject)
        Case "IPM.Contact"
            MsgBox(0,"Contact",$oItem.FullName)
        Case "IPM.Note"
            MsgBox(0,"Note",$oItem.Subject)
        Case "IPM.Activity"
            MsgBox(0,"Activity",$oItem.Subject)
        Case "IPM.StickyNote"
            MsgBox(0,"Sticky Note",$oItem.Subject)
        Case "IPM.Task"
            MsgBox(0,"Task Item",$oItem.DueDate)
    EndSwitch
EndFunc
Edited by footswitch
Posted

footswitch,

I think the same can be done using function _OL_FolderSelectionGet. It returns an array with information about all selected items in the active explorer. This information (item object, EntryID, object class) can be passed to other functions of the UDF ;)

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

 

Posted

Could you please try this code? It should list all the accessed mailboxes.

#include <OutlookEX.au3>

Global $oOutlook = _OL_Open()
$oOL_Namespace = $oOutlook.GetNamespace("MAPI")
For $oFolder In $oOL_Namespace.Folders
    ConsoleWrite($oFolder.Name & @CRLF)
Next

AWESOME. It works ;)

My setup, as mentioned before, is:

Exchange 2003

Outlook 2003 SP3

Cached Exchange Mode

Thank you so much.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...