water Posted December 3, 2015 Author Posted December 3, 2015 I modified the script a bit and it is now running on my PC until it crashes.The GUI is now created once in the body of the script the event function only adds new entries.This version grabs all unread mails when started and displays them in the window. Every new mail is added at the end of the Listview.expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <ListViewConstants.au3> #include <OutlookEX.au3> _OL_ErrorNotify(4) Global $oOL = '' If Not MsgBox(4, 'Outlook Rules', 'You want to run Outlook rule checker?') = 6 Then Exit MsgBox(0, 'Quitting App', 'The script will now close.') $oOL = ObjCreate("Outlook.Application") Global $oEvent = ObjEvent($oOL, "oOApp_") Global $hGUI = GUICreate('New Outlook Email Alert', 800, 200, -1, -1, $WS_SIZEBOX, $WS_EX_TOPMOST) Global $idOKButton = GUICtrlCreateButton("OK", 110, 160, 85, 25) Global $idListview = GUICtrlCreateListView("From|Subject", 10, 10, 780, 110) GUICtrlSetFont($idListview, Default, Default, Default, "Consolas") ; Monospaced font ; Get all unread mails and fill the window Global $aFolder = _OL_FolderAccess($oOL, "", $olFolderInbox) Global $aItems = _OL_ItemFind($oOL, $aFolder[1], $olMail, "[UnRead]=True", "", "", "SenderName,Subject") If IsArray($aItems) Then For $i = 1 To $aItems[0][0] GUICtrlCreateListViewItem($aItems[$i][0] & '|' & $aItems[$i][1], $idListview) Next EndIf GUISetState(@SW_SHOW, $hGUI) _GUICtrlListView_SetColumnWidth($idListview, 0, $LVSCW_AUTOSIZE) _GUICtrlListView_SetColumnWidth($idListview, 1, $LVSCW_AUTOSIZE) ; Now resize the GUI and ListView to fit Global $iMaxWidth = 0 For $i = 0 To 1 $iMaxWidth += _GUICtrlListView_GetColumnWidth($idListview, $i) Next WinMove($hGUI, "", Default, Default, $iMaxWidth + 40) ; Just a quick approx - we can refine this ControlMove($hGUI, "", $idListview, 10, 10, $iMaxWidth + 25) WinActivate($hGUI) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idOKButton GUISetState(@SW_HIDE, $hGUI) ExitLoop EndSwitch WEnd Func oOApp_NewMailEx($sOL_EntryId) Global $oOL_Item = $oOL.Session.GetItemFromID($sOL_EntryId, Default) If @error Then Return ConsoleWrite("ERROR $oOL.Session.GetItemFromID = " & @error & '<' & @CRLF) Local $sSenderName = $oOL_Item.SenderName Local $sSubject = $oOL_Item.Subject GUICtrlCreateListViewItem($sSenderName & '|' & $sSubject, $idListview) ; Now resize the GUI and ListView to fit Global $iMaxWidth = 0 For $i = 0 To 1 $iMaxWidth += _GUICtrlListView_GetColumnWidth($idListview, $i) Next WinMove($hGUI, "", Default, Default, $iMaxWidth + 40) ; Just a quick approx - we can refine this ControlMove($hGUI, "", $idListview, 10, 10, $iMaxWidth + 25) WinActivate($hGUI) EndFunc ;==>oOApp_NewMailEx My UDFs and Tutorials: Reveal hidden contents 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
nitekram Posted December 3, 2015 Posted December 3, 2015 (edited) On 12/3/2015 at 3:19 PM, water said: I modified the script a bit and it is now running on my PC until it crashes.expandpopupDo we know why it is crashing?EDITAnd mine runs only once...it shows newest email, then closes?Edit 2I fixed that, as the OK button was closing out of the While loop Edited December 3, 2015 by nitekram 2¢ Reveal hidden contents All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." Reveal hidden contents WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator
water Posted December 3, 2015 Author Posted December 3, 2015 Not yet.But maybe it doesn't crash any longer as I have moved the GUI creation into the main script My UDFs and Tutorials: Reveal hidden contents 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
nitekram Posted December 3, 2015 Posted December 3, 2015 I will test for a while...thanks for your help. 2¢ Reveal hidden contents All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." Reveal hidden contents WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator
water Posted December 4, 2015 Author Posted December 4, 2015 (edited) Extended the script a bit:Displays the received date/time of the mailyou can sort the listview by clicking on the column headersdouble click a mail to open itpressing F5 updates the displayIt should be easy to implement a right click context menu to delete, forward etc. mails.What I would add in addition is a timer to refresh the Listview so read mails get removed.expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <ListViewConstants.au3> #include <OutlookEX.au3> GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") _OL_ErrorNotify(4) If MsgBox($MB_YESNO, 'Outlook Rules', 'You want to run Outlook rule checker?') <> $IDYES Then Exit MsgBox($MB_OK, 'Quitting App', 'The script will now close.') Global $aItems, $bSort = False ; Sort directioen for _GUICtrlListView_SimpleSort Global $oOL = ObjCreate("Outlook.Application") Global $oEvent = ObjEvent($oOL, "oOApp_") Global $aFolder = _OL_FolderAccess($oOL, "", $olFolderInbox) Global $hGUI = GUICreate('New Outlook Email Alert', 800, 200, -1, -1, $WS_SIZEBOX, $WS_EX_TOPMOST) Global $idOKButton = GUICtrlCreateButton("OK", 110, 160, 85, 25) Global $idListview = GUICtrlCreateListView("Received|From|Subject", 10, 10, 780, 110) Global $idF5Dummy = GUICtrlCreateDummy() ; Set accelerator for F5 Global $asAccelKeys[1][2] = [["{F5}", $idF5Dummy]] GUISetAccelerators($asAccelKeys) GUICtrlSetFont($idListview, Default, Default, Default, "Consolas") ; Monospaced font _RefreshListview() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idOKButton GUISetState(@SW_HIDE, $hGUI) ExitLoop Case $idF5Dummy ; Refresh _RefreshListview() EndSwitch WEnd Func oOApp_NewMailEx($sOL_EntryId) _RefreshListview() EndFunc ;==>oOApp_NewMailEx ;--------------------- ; Process GUI messages ;--------------------- Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $tInfo, $iItem Local $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) Local $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") Local $iCode = DllStructGetData($tNMHDR, "Code") Switch $iCode Case $LVN_COLUMNCLICK ; A column was clicked $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam) _GUICtrlListView_SimpleSort(GUICtrlGetHandle($idListview), $bSort, DllStructGetData($tInfo, "SubItem")) Case $NM_DBLCLK ; Sent by a list-view control when the user selects an item by double-clicking $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam) $iItem = DllStructGetData($tInfo, "Item") _OL_ItemDisplay($oOL, $aItems[$iItem + 1][3]) EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY ;----------------------------------------- ; Get all unread mails and fill the window ;----------------------------------------- Func _RefreshListview() $aItems = _OL_ItemFind($oOL, $aFolder[1], $olMail, "[UnRead]=True", "", "", "ReceivedTime,SenderName,Subject,EntryID") If Not IsArray($aItems) Then Return _GUICtrlListView_BeginUpdate($idListview) _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($idListview)) For $i = 1 To $aItems[0][0] $aItems[$i][0] = StringRegExpReplace($aItems[$i][0], "(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})", "$1/$2/$3 $4:$5:$6") GUICtrlCreateListViewItem($aItems[$i][0] & '|' & $aItems[$i][1] & '|' & $aItems[$i][2], $idListview) Next GUISetState(@SW_SHOW, $hGUI) _GUICtrlListView_SetColumnWidth($idListview, 0, $LVSCW_AUTOSIZE) ; Date/time _GUICtrlListView_SetColumnWidth($idListview, 1, $LVSCW_AUTOSIZE) ; From _GUICtrlListView_SetColumnWidth($idListview, 2, $LVSCW_AUTOSIZE) ; Subject ; Now resize the GUI and ListView to fit Global $iMaxWidth = 0 For $i = 0 To 2 $iMaxWidth += _GUICtrlListView_GetColumnWidth($idListview, $i) Next _GUICtrlListView_EndUpdate($idListview) WinMove($hGUI, "", Default, Default, $iMaxWidth + 40) ; Just a quick approx - we can refine this ControlMove($hGUI, "", $idListview, 10, 10, $iMaxWidth + 25) WinActivate($hGUI) EndFunc ;==>_RefreshListview Edited December 4, 2015 by water My UDFs and Tutorials: Reveal hidden contents 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
nitekram Posted December 4, 2015 Posted December 4, 2015 I am unable to get the email to open with double click...am I missing something. I do like the idea of removing the read emails, as well as showing the time stamp. Thanks for the update! 2¢ Reveal hidden contents All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." Reveal hidden contents WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator
water Posted December 4, 2015 Author Posted December 4, 2015 Just upated the code. Double click should work now. My UDFs and Tutorials: Reveal hidden contents 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
nitekram Posted December 4, 2015 Posted December 4, 2015 (edited) I am testing now, but notice when I send an email to myself, it does not show my name nor my subject. In previous version, I have been able to see that.I also changed it a bit, so that it could remain active, after pressing the OK button, as it is set in your script to exit the loop, which will end the script.I was able to open an email though, and that is a really cool addition. EDIT - it appears that the newest script, will not show emails that have rules to move it to a different folder? Meaning the display is blank for that email. Edited December 4, 2015 by nitekram 2¢ Reveal hidden contents All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." Reveal hidden contents WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator
water Posted December 4, 2015 Author Posted December 4, 2015 Added the right click function (only display works at the moment).Brushed up the GUI so the controls stay in place even when you resize the GUI"OK" not only minimizes the GUIexpandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <ListViewConstants.au3> #include <OutlookEX.au3> GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") _OL_ErrorNotify(4) If MsgBox($MB_YESNO, 'Outlook Rules', 'You want to run Outlook rule checker?') <> $IDYES Then Exit MsgBox($MB_OK, 'Quitting App', 'The script will now close.') Global $aItems, $iItem, $bSort = False ; Sort directioen for _GUICtrlListView_SimpleSort Global $oOL = ObjCreate("Outlook.Application") Global $oEvent = ObjEvent($oOL, "oOApp_") Global $aFolder = _OL_FolderAccess($oOL, "", $olFolderInbox) Global $hGUI = GUICreate('New Outlook Email Alert', 800, 200, -1, -1, $WS_SIZEBOX, $WS_EX_TOPMOST) Global $idOKButton = GUICtrlCreateButton("OK", 10, 150, 85, 25) GUICtrlSetResizing(-1, BitOR($GUI_DOCKBOTTOM, $GUI_DOCKLEFT, $GUI_DOCKWIDTH, $GUI_DOCKHEIGHT)) Global $idListview = GUICtrlCreateListView("Received|From|Subject", 10, 10, 780, 130) GUICtrlSetResizing(-1, BitOR($GUI_DOCKTOP, $GUI_DOCKLEFT, $GUI_DOCKRIGHT, $GUI_DOCKBOTTOM)) ; Context Menu Global $idCM = GUICtrlCreateContextMenu($idListview) Global $idCM_Display = GUICtrlCreateMenuItem("Display", $idCM) Global $idCM_Reply = GUICtrlCreateMenuItem("Reply", $idCM) GUICtrlCreateMenuItem("", $idCM) Global $idCM_Delete = GUICtrlCreateMenuItem("Delete", $idCM) Global $idF5Dummy = GUICtrlCreateDummy() ; Set accelerator for F5 Global $asAccelKeys[1][2] = [["{F5}", $idF5Dummy]] GUISetAccelerators($asAccelKeys) GUICtrlSetFont($idListview, Default, Default, Default, "Consolas") ; Monospaced font _RefreshListview() GUISetState(@SW_SHOW, $hGUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idOKButton GUISetState(@SW_MINIMIZE, $hGUI) Case $idF5Dummy ; Refresh _RefreshListview() Case $idCM_Display _OL_ItemDisplay($oOL, $aItems[$iItem + 1][3]) EndSwitch WEnd Func oOApp_NewMailEx($sOL_EntryId) _RefreshListview() EndFunc ;==>oOApp_NewMailEx ;--------------------- ; Process GUI messages ;--------------------- Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $tInfo, $iItem Local $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) Local $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") Local $iCode = DllStructGetData($tNMHDR, "Code") Switch $iCode Case $LVN_COLUMNCLICK ; A column was clicked $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam) _GUICtrlListView_SimpleSort(GUICtrlGetHandle($idListview), $bSort, DllStructGetData($tInfo, "SubItem")) Case $NM_DBLCLK ; Sent by a list-view control when the user selects an item by double-clicking $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam) $iItem = DllStructGetData($tInfo, "Item") _OL_ItemDisplay($oOL, $aItems[$iItem + 1][3]) Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the right mouse button $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam) $iItem = DllStructGetData($tInfo, "Item") ; Disable context menu when no listview item was selected If $iItem = -1 Then GUICtrlSetState($idCM_Display, $GUI_DISABLE) GUICtrlSetState($idCM_Delete, $GUI_DISABLE) GUICtrlSetState($idCM_Reply, $GUI_DISABLE) Else GUICtrlSetState($idCM_Display, $GUI_ENABLE) GUICtrlSetState($idCM_Delete, $GUI_ENABLE) GUICtrlSetState($idCM_Reply, $GUI_ENABLE) EndIf EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY ;----------------------------------------- ; Get all unread mails and fill the window ;----------------------------------------- Func _RefreshListview() $aItems = _OL_ItemFind($oOL, $aFolder[1], $olMail, "[UnRead]=True", "", "", "ReceivedTime,SenderName,Subject,EntryID") If Not IsArray($aItems) Then Return _GUICtrlListView_BeginUpdate($idListview) _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($idListview)) For $i = 1 To $aItems[0][0] $aItems[$i][0] = StringRegExpReplace($aItems[$i][0], "(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})", "$1/$2/$3 $4:$5:$6") GUICtrlCreateListViewItem($aItems[$i][0] & '|' & $aItems[$i][1] & '|' & $aItems[$i][2], $idListview) Next _GUICtrlListView_SetColumnWidth($idListview, 0, $LVSCW_AUTOSIZE) ; Date/time _GUICtrlListView_SetColumnWidth($idListview, 1, $LVSCW_AUTOSIZE) ; From _GUICtrlListView_SetColumnWidth($idListview, 2, $LVSCW_AUTOSIZE) ; Subject ; Now resize the GUI and ListView to fit Global $iMaxWidth = 0 For $i = 0 To 2 $iMaxWidth += _GUICtrlListView_GetColumnWidth($idListview, $i) Next _GUICtrlListView_EndUpdate($idListview) WinMove($hGUI, "", Default, Default, $iMaxWidth + 40) ; Just a quick approx - we can refine this ControlMove($hGUI, "", $idListview, 10, 10, $iMaxWidth + 25) WinActivate($hGUI) EndFunc ;==>_RefreshListview My UDFs and Tutorials: Reveal hidden contents 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
water Posted December 4, 2015 Author Posted December 4, 2015 On 12/4/2015 at 2:41 PM, nitekram said: EDIT - it appears that the newest script, will not show emails that have rules to move it to a different folder? Meaning the display is blank for that email.Correct.The problem is that mails moved to another folder get a new EntryID. My UDFs and Tutorials: Reveal hidden contents 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
nitekram Posted December 4, 2015 Posted December 4, 2015 On 12/4/2015 at 2:59 PM, water said: Correct.The problem is that mails moved to another folder get a new EntryID.But up until I started using your current script, I could see the emails - maybe they were coming in faster in previous version, and therefore had time to display? Is there anything that can change that? Like list all unread emails, no matter where they reside in folders? 2¢ Reveal hidden contents All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." Reveal hidden contents WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator
water Posted December 4, 2015 Author Posted December 4, 2015 Are this subfolders of your inbox? My UDFs and Tutorials: Reveal hidden contents 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
nitekram Posted December 4, 2015 Posted December 4, 2015 Yes, I have about 15 subfolders, and 2 of them have 2 to 4 subfolders as well. 2¢ Reveal hidden contents All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." Reveal hidden contents WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator
water Posted December 4, 2015 Author Posted December 4, 2015 (edited) Then set the first line in function _RefreshListView to$aItems = _OL_ItemFind($oOL, $aFolder[1], $olMail, "[UnRead]=True", "", "", "ReceivedTime,SenderName,Subject,EntryID", "", 1) Edited December 4, 2015 by water My UDFs and Tutorials: Reveal hidden contents 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
nitekram Posted December 4, 2015 Posted December 4, 2015 That worked...thanks.How do you go about deleting and email, as I have right clicked on the email test, and left clicked on the delete and did a refresh, but it does not remove it from the GUI nor Outlook.Also, when I have tried to sort on the received, it appears that it sort of sorts it, but they are not shorted correctly. This appears to have been cleared up, but will test again, after I get a few more emails. 2¢ Reveal hidden contents All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." Reveal hidden contents WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator
water Posted December 4, 2015 Author Posted December 4, 2015 (edited) Here's the latest version:Implemented all functions from the context menu"OK" and "Exit" only minimize the GUI. It pops up as soon as a new mail arrives.Edit: GUI gets minimized when there are no new mails to display (either on startup, refresh or when you deleted the last unread mail)expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <ListViewConstants.au3> #include <OutlookEX.au3> Global $aItems, $iItem, $bDisplay = True, $oReply, $bSort = False ; Sort directioen for _GUICtrlListView_SimpleSort GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") AdlibRegister("_RefreshListview", 1000 * 60) ; Refresh each minute _OL_ErrorNotify(4) If MsgBox($MB_YESNO, 'Outlook Rules', 'You want to run Outlook rule checker?') <> $IDYES Then Exit MsgBox($MB_OK, 'Quitting App', 'The script will now close.') Global $oOL = ObjCreate("Outlook.Application") Global $oEvent = ObjEvent($oOL, "oOApp_") Global $aFolder = _OL_FolderAccess($oOL, "", $olFolderInbox) Global $hGUI = GUICreate('New Outlook Email Alert', 800, 200, -1, -1, $WS_SIZEBOX, $WS_EX_TOPMOST) Global $idOKButton = GUICtrlCreateButton("OK", 10, 150, 85, 25) GUICtrlSetResizing(-1, BitOR($GUI_DOCKBOTTOM, $GUI_DOCKLEFT, $GUI_DOCKWIDTH, $GUI_DOCKHEIGHT)) Global $idListview = GUICtrlCreateListView("Received|From|Subject", 10, 10, 780, 130) GUICtrlSetResizing(-1, BitOR($GUI_DOCKTOP, $GUI_DOCKLEFT, $GUI_DOCKRIGHT, $GUI_DOCKBOTTOM)) ; Context Menu Global $idCM = GUICtrlCreateContextMenu($idListview) Global $idCM_Display = GUICtrlCreateMenuItem("Display", $idCM) Global $idCM_Reply = GUICtrlCreateMenuItem("Reply", $idCM) GUICtrlCreateMenuItem("", $idCM) Global $idCM_Delete = GUICtrlCreateMenuItem("Delete", $idCM) Global $idF5Dummy = GUICtrlCreateDummy() ; Set accelerator for F5 Global $asAccelKeys[1][2] = [["{F5}", $idF5Dummy]] GUISetAccelerators($asAccelKeys) GUICtrlSetFont($idListview, Default, Default, Default, "Consolas") ; Monospaced font GUISetState(@SW_SHOW, $hGUI) _RefreshListview() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idOKButton GUISetState(@SW_MINIMIZE, $hGUI) Case $idF5Dummy ; Refresh $bDisplay = True _RefreshListview() Case $idCM_Display _OL_ItemDisplay($oOL, $aItems[$iItem + 1][3]) Case $idCM_Reply $oReply = _OL_ItemReply($oOL, $aItems[$iItem + 1][3]) _OL_ItemDisplay($oOL, $oReply) Case $idCM_Delete If MsgBox($MB_YESNO, 'Outlook Rules', 'You really want to delete this mail?') = $IDYES Then _OL_ItemDelete($oOL, $aItems[$iItem + 1][3]) $bDisplay = True _RefreshListview() EndIf EndSwitch WEnd Func oOApp_NewMailEx($sOL_EntryId) $bDisplay = True _RefreshListview() EndFunc ;==>oOApp_NewMailEx ;--------------------- ; Process GUI messages ;--------------------- Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $tInfo Local $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) Local $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") Local $iCode = DllStructGetData($tNMHDR, "Code") Switch $iCode Case $LVN_COLUMNCLICK ; A column was clicked $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam) _GUICtrlListView_SimpleSort(GUICtrlGetHandle($idListview), $bSort, DllStructGetData($tInfo, "SubItem")) Case $NM_DBLCLK ; Sent by a list-view control when the user selects an item by double-clicking $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam) $iItem = DllStructGetData($tInfo, "Item") _OL_ItemDisplay($oOL, $aItems[$iItem + 1][3]) Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the right mouse button $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam) $iItem = DllStructGetData($tInfo, "Item") ; Disable context menu when no listview item was selected If $iItem = -1 Then GUICtrlSetState($idCM_Display, $GUI_DISABLE) GUICtrlSetState($idCM_Delete, $GUI_DISABLE) GUICtrlSetState($idCM_Reply, $GUI_DISABLE) Else GUICtrlSetState($idCM_Display, $GUI_ENABLE) GUICtrlSetState($idCM_Delete, $GUI_ENABLE) GUICtrlSetState($idCM_Reply, $GUI_ENABLE) EndIf EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY ;----------------------------------------- ; Get all unread mails and fill the window ;----------------------------------------- Func _RefreshListview() $aItems = _OL_ItemFind($oOL, $aFolder[1], $olMail, "[UnRead]=True", "", "", "ReceivedTime,SenderName,Subject,EntryID", "", 1) If Not IsArray($aItems) Or $aItems[0][0] = 0 Then GUISetState(@SW_MINIMIZE, $hGUI) $bDisplay = False Return EndIf _GUICtrlListView_BeginUpdate($idListview) _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($idListview)) For $i = 1 To $aItems[0][0] $aItems[$i][0] = StringRegExpReplace($aItems[$i][0], "(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})", "$1/$2/$3 $4:$5:$6") GUICtrlCreateListViewItem($aItems[$i][0] & '|' & $aItems[$i][1] & '|' & $aItems[$i][2], $idListview) Next _GUICtrlListView_SetColumnWidth($idListview, 0, $LVSCW_AUTOSIZE) ; Date/time _GUICtrlListView_SetColumnWidth($idListview, 1, $LVSCW_AUTOSIZE) ; From _GUICtrlListView_SetColumnWidth($idListview, 2, $LVSCW_AUTOSIZE) ; Subject ; Now resize the GUI and ListView to fit Global $iMaxWidth = 0 For $i = 0 To 2 $iMaxWidth += _GUICtrlListView_GetColumnWidth($idListview, $i) Next _GUICtrlListView_EndUpdate($idListview) If $bDisplay = True Then WinMove($hGUI, "", Default, Default, $iMaxWidth + 40) ; Just a quick approx - we can refine this ControlMove($hGUI, "", $idListview, 10, 10, $iMaxWidth + 25) WinActivate($hGUI) GUISetState(@SW_RESTORE, $hGUI) EndIf $bDisplay = False EndFunc ;==>_RefreshListview Edited December 4, 2015 by water My UDFs and Tutorials: Reveal hidden contents 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
nitekram Posted December 5, 2015 Posted December 5, 2015 So far, no crashes! Is there a command that I can use to say that I read the email - without actually opening the email? 2¢ Reveal hidden contents All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." Reveal hidden contents WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator
water Posted December 5, 2015 Author Posted December 5, 2015 Should be easy to implement. I will post a modified version quite soon.Whne you select to display one of the messages and you want to close the display window do you get the info message that the mail item has been modified?If yes, should this message be suppressed? My UDFs and Tutorials: Reveal hidden contents 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
nitekram Posted December 5, 2015 Posted December 5, 2015 I do not believe so. At least I have not seen it 2¢ Reveal hidden contents All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." Reveal hidden contents WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator
water Posted December 5, 2015 Author Posted December 5, 2015 With Outlook 2010 I get a message that the mail item has been modified (the unread property has been changed to False) and if the modification should be saved when I close the display window. My UDFs and Tutorials: Reveal hidden contents 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
Recommended Posts