Jump to content

Read Outlook TreeView


Recommended Posts

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!

Link to comment
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 2022-02-19 - Version 1.6.1.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 (NEW 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

:D

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

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 2022-02-19 - Version 1.6.1.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 (NEW 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 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?

Link to comment
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 2022-02-19 - Version 1.6.1.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 (NEW 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

  • Recently Browsing   0 members

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