Jump to content



Photo

Read Outlook TreeView


  • Please log in to reply
8 replies to this topic

#1 mattschinkel

mattschinkel

    Seeker

  • Active Members
  • 48 posts

Posted 14 July 2012 - 09:57 AM

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!





#2 water

water

    ?

  • MVPs
  • 10,693 posts

Posted 14 July 2012 - 10:06 AM

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.

UDFs:

Active Directory (2012-10-12 - Version 1.3.0.0 released) - Download - General Help & Support - Example Scripts - Wiki

OutlookEX (2012-10-07 - Version 0.9.0.0 released) - Download - General Help & Support - Example Scripts - Wiki

ExcelChart (2013-01-21 - Version 0.3.1.1 released) - Download - General Help & Support - Example Scripts

WordEX (2012-12-29 - Version 1.3 released) - Download

ExcelEX (2013-05-11 - Alpha 4 released) - Download


#3 mattschinkel

mattschinkel

    Seeker

  • Active Members
  • 48 posts

Posted 14 July 2012 - 10:30 AM

Thanks, This is perfect!

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

#4 water

water

    ?

  • MVPs
  • 10,693 posts

Posted 14 July 2012 - 10:32 AM

:D

UDFs:

Active Directory (2012-10-12 - Version 1.3.0.0 released) - Download - General Help & Support - Example Scripts - Wiki

OutlookEX (2012-10-07 - Version 0.9.0.0 released) - Download - General Help & Support - Example Scripts - Wiki

ExcelChart (2013-01-21 - Version 0.3.1.1 released) - Download - General Help & Support - Example Scripts

WordEX (2012-12-29 - Version 1.3 released) - Download

ExcelEX (2013-05-11 - Alpha 4 released) - Download


#5 mattschinkel

mattschinkel

    Seeker

  • Active Members
  • 48 posts

Posted 14 July 2012 - 10:41 AM

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

#6 water

water

    ?

  • MVPs
  • 10,693 posts

Posted 14 July 2012 - 10:46 AM

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.

UDFs:

Active Directory (2012-10-12 - Version 1.3.0.0 released) - Download - General Help & Support - Example Scripts - Wiki

OutlookEX (2012-10-07 - Version 0.9.0.0 released) - Download - General Help & Support - Example Scripts - Wiki

ExcelChart (2013-01-21 - Version 0.3.1.1 released) - Download - General Help & Support - Example Scripts

WordEX (2012-12-29 - Version 1.3 released) - Download

ExcelEX (2013-05-11 - Alpha 4 released) - Download


#7 mattschinkel

mattschinkel

    Seeker

  • Active Members
  • 48 posts

Posted 15 July 2012 - 01:34 AM

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?

#8 mattschinkel

mattschinkel

    Seeker

  • Active Members
  • 48 posts

Posted 15 July 2012 - 02:24 AM

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.

#9 water

water

    ?

  • MVPs
  • 10,693 posts

Posted 15 July 2012 - 08:48 AM

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"

UDFs:

Active Directory (2012-10-12 - Version 1.3.0.0 released) - Download - General Help & Support - Example Scripts - Wiki

OutlookEX (2012-10-07 - Version 0.9.0.0 released) - Download - General Help & Support - Example Scripts - Wiki

ExcelChart (2013-01-21 - Version 0.3.1.1 released) - Download - General Help & Support - Example Scripts

WordEX (2012-12-29 - Version 1.3 released) - Download

ExcelEX (2013-05-11 - Alpha 4 released) - Download





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users