Sign in to follow this  
Followers 0
mattschinkel

Read Outlook TreeView

9 posts in this topic

Hello, I am having trouble getting the text out of the treeview in Microsoft Outlook. I'd like to write a script that pops up a message box when my inbox shows unread items like; inbox(1).

I know I can create rules, but rules do not work for shared email addresses, and I can't use the outlook UDF because data is stored on the exchange server, not locally.

I am able to get the handle, but not the control ID or text of any items. Here's what I have so far:

#include <GuiTreeView.au3>
Opt("WinTitleMatchMode", 2)

$OutlookTree = ControlGetHandle("Microsoft Outlook", "", "[CLASS:NetUIHWND;INSTANCE:1]")
ConsoleWrite("Handle: " & $OutlookTree & @crlf)

$item = GUICtrlRead($OutlookTree) ; Get the controlID of the current selected treeview
ConsoleWrite("Item control ID: " & $item & @crlf)

$text = GUICtrlRead($item, 1) ; Get the text of the treeview item
ConsoleWrite("Item selected text: " & $text & @crlf)

$text = _GUICtrlTreeView_GetItemParam($OutlookTree)
ConsoleWrite("GetItemParam: " & $text & @crlf)

The output is:

Handle: 0x0005040E

Item control ID: 0

Item selected text: 0

GetItemParam: False

Please help!

Share this post


Link to post
Share on other sites



You could use my extended OutlookEX UDF.

You can either handle the event that's triggered when a new mail arrives. Or if you need to handle mails that arrive while Outlook or your script isn't active you can search a folder for the number of unread mails.


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

Thanks, This is perfect!

_OL_Example_NewMail_Event.au3 is exactally what I need, I don't even need to modify it :)

Share this post


Link to post
Share on other sites
:D

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

Well... I spoke too soon. It works perfectly for anything in my personal email, but not for the group email account :(

Share this post


Link to post
Share on other sites

Then please have a look at the example script _OL_ItemFind.au3 - example 4. It searches a folder for unread items and returns just the number.


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 can't search any folder since there isn't one. The mail comes from an networked exchange server. Maybe I should also mention that I can't setup any rules for this group email.

I will need to read the outlook treeview to see if any mail arrives. Any idea's?

Share this post


Link to post
Share on other sites

Well, I did try your _OL_ItemFind, It seems to work but it takes way too long. I still need to read the outlook treeview to see if any mail arrives unless there is another solution.

Share this post


Link to post
Share on other sites

This should run faster:

$aFolder = _OL_FolderAccess(...)
$aFolderInfo = _OL_FolderGet($oOL, $aFolder[1])
returns an array where element 7 is the "Number of unread items in the folder"

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