water Posted March 9, 2016 Author Posted March 9, 2016 That's exactly what you need. 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
water Posted May 9, 2016 Author Posted May 9, 2016 Version 1.2.0.0 of the UDF has been released. Please test before using in production! For download please see my signature. Skysnake 1 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
DasIch Posted May 24, 2016 Posted May 24, 2016 Hey water, i really like your work (espacially the AD UDF - its just great!) and tried now this UDF here. Is there any way to check a mailbox for new emails and get an alert for it? i mean like: Popup you have to close with title and time containing. Thanks in advance, Robert
water Posted May 24, 2016 Author Posted May 24, 2016 Yes, there is. Outlook creates events which can be grabbed by an AutoIt script. Please check the Outlook Example Scripts thread (link is in my signature) for the _OL_Example_NewMail_Event.au3 script. DasIch 1 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
DasIch Posted May 24, 2016 Posted May 24, 2016 Dear water, thanks for your fast reply! I got it to work in my own mailbox. But the problem ist, that its an shared mailbox. I cannot access the mailbox. Here my code so far: Spoiler expandcollapse popup#AutoIt3Wrapper_Au3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #AutoIt3Wrapper_Au3Check_Stop_OnWarning=Y #include <OutlookEX.au3> HotKeySet("+!e", "_Exit") ;Shift-Alt-E to Exit the script Global $oOApp = ObjCreate("Outlook.Application") Global $test = ObjEvent($oOApp, "oOApp_") Global $aResult = _OL_FolderGet($oOApp) Global $Entry = $aResult[4] Global $Store = $aResult[3] ;~ _ArrayDisplay($aResult) ;~ MsgBox(64, "", "Entry: " & $Entry & @CRLF & "Store: " & $Store) While 1 Sleep(10) WEnd ; Outlook 2007 - NewMailEx event - http://msdn.microsoft.com/en-us/library/bb147646%28v=office.12%29.aspx Func oOApp_NewMailEx() Local $oOL_Item = $oOApp.Session.GetItemFromID($Entry, Default) local $whole = $oOL_Item.ReceivedTime local $year, $month, $day, $hour, $min $year = StringLeft($whole, 4) $whole = StringTrimLeft($whole, 4) $month = StringLeft($whole, 2) $whole = StringTrimLeft($whole, 2) $day = StringLeft($whole, 2) $whole = StringTrimLeft($whole, 2) $hour = StringLeft($whole, 2) $whole = StringTrimLeft($whole, 2) $min = StringLeft($whole, 2) $whole = $day & "." & $month & "." & $year & " - " & _ $hour & ":" & $min MsgBox(64, "Neue Nachricht", "Neue Nachricht erhalten!" & @CRLF & @CRLF & _ "Datum:" & @TAB & $whole & @CRLF & _ "Von:" & @TAB & $oOL_Item.SenderName & @CRLF & _ "Betreff:" & @TAB & $oOL_Item.Subject) EndFunc ;==>oOApp_NewMailEx Func _Exit() Exit EndFunc ;==>_Exit
DasIch Posted May 24, 2016 Posted May 24, 2016 I cant edit my post.. I also tried Local $oOL_Item = $oOApp.Session.GetItemFromID($Entry, $Store) But that did not change anything. Just for your info: I selected the shared mailbox on start to get the right ID's.
water Posted May 24, 2016 Author Posted May 24, 2016 I think you need to have 5 posts at least before you can edit your posts. I'm just playing with the Example Script right now. Hope to come up with a solution DasIch 1 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
DasIch Posted May 24, 2016 Posted May 24, 2016 Thank you! Are the IDs i get from _OL_FolderGet() (Store- & EntryID) the same IDs i need for the outlook method GetItemFromID(EntryIDItem, EntryIDStore)?
water Posted May 24, 2016 Author Posted May 24, 2016 This works for a shared folder. Replace "test@comapy.org" with the address of your shared folder (as seen in the store listings in the left pane): #include <OutlookEX.au3> HotKeySet("+!e", "_Exit") ;Shift-Alt-E to Exit the script Global $oOApp = ObjCreate("Outlook.Application") Global $oEvent = ObjEvent($oOApp, "oOApp_") Global $aFolder = _OL_FolderAccess($oOApp, "test@company.org", $olFolderInbox) While 1 Sleep(10) WEnd ; Outlook 2007 - NewMailEx event - http://msdn.microsoft.com/en-us/library/bb147646%28v=office.12%29.aspx Func oOApp_NewMailEx($sEntryIDCollection) Local $asEntryIDs = StringSplit($sEntryIDCollection, ",") For $i = 1 To $asEntryIDs[0] $oItem = $oOApp.Session.GetItemFromID($asEntryIDs[$i], $aFolder[3]) ConsoleWrite($oItem.Subject & @CRLF) Next EndFunc ;==>oOApp_NewMailEx Func _Exit() Exit EndFunc ;==>_Exit 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
water Posted May 24, 2016 Author Posted May 24, 2016 10 minutes ago, DasIch said: Thank you! Are the IDs i get from _OL_FolderGet() (Store- & EntryID) the same IDs i need for the outlook method GetItemFromID(EntryIDItem, EntryIDStore)? No, you get the Store- and EntryID for the FOLDER. But fir getItemFromID you need this properties of the MAIL item. As you can see in my above example I grab the StoreID from _OL_FolderAccess and the Items EntryID from the parameter passed by the event. Unfortunately the NewMaiLEX event is fired for every Store but the StoreID is only valid for the shared mailbox and hence GetItemFromID would return an error for all other stores. Either a COM error handler should be added to ignore all "invalid" stores or another approach should be tried. 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
water Posted May 24, 2016 Author Posted May 24, 2016 Unfortunately the ItemAdd event I had in mind only works for VBA. So we need to handle the COM error to ignore mails arriving in another Store. 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
water Posted May 24, 2016 Author Posted May 24, 2016 OK. This works. All COM errors are ignored in the event function: #include <OutlookEX.au3> HotKeySet("+!e", "_Exit") ;Shift-Alt-E to Exit the script Global $oOApp = _OL_Open() Global $oEvent = ObjEvent($oOApp, "oOApp_") Global $aFolder = _OL_FolderAccess($oOApp, "test@company.org", $olFolderInbox) While 1 Sleep(10) WEnd ; Outlook 2007 - NewMailEx event - http://msdn.microsoft.com/en-us/library/bb147646%28v=office.12%29.aspx Func oOApp_NewMailEx($sEntryIDCollection) Local $asEntryIDs = StringSplit($sEntryIDCollection, ",") For $i = 1 To $asEntryIDs[0] $oItem = $oOApp.Session.GetItemFromID($asEntryIDs[$i], $aFolder[3]) If @error Then ContinueLoop ConsoleWrite($oItem.Subject & @CRLF) Next EndFunc ;==>oOApp_NewMailEx Func _Exit() Exit EndFunc ;==>_Exit 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
DasIch Posted May 24, 2016 Posted May 24, 2016 hm. in my case it is not working. not even a reaction when a mail arrives in that mailbox. strange..
water Posted May 24, 2016 Author Posted May 24, 2016 OK, lets add some error checking: #include <OutlookEX.au3> HotKeySet("+!e", "_Exit") ;Shift-Alt-E to Exit the script Global $oOApp = _OL_Open() ConsoleWrite("_OL_Open: " & @error & @CRLF) Global $oEvent = ObjEvent($oOApp, "oOApp_") ConsoleWrite("ObjEvent: " & @error & @CRLF) Global $aFolder = _OL_FolderAccess($oOApp, "test@company.org", $olFolderInbox) ConsoleWrite("_OL_FolderAccess: " & @error & @CRLF) While 1 Sleep(10) WEnd ; Outlook 2007 - NewMailEx event - http://msdn.microsoft.com/en-us/library/bb147646%28v=office.12%29.aspx Func oOApp_NewMailEx($sEntryIDCollection) ConsoleWrite("Eventhandler called: " & $sEntryIDCollection & @CRLF) Local $asEntryIDs = StringSplit($sEntryIDCollection, ",") For $i = 1 To $asEntryIDs[0] $oItem = $oOApp.Session.GetItemFromID($asEntryIDs[$i], $aFolder[3]) If @error Then ContinueLoop ConsoleWrite($oItem.Subject & @CRLF) Next EndFunc ;==>oOApp_NewMailEx Func _Exit() Exit EndFunc ;==>_Exit What do you get in the SciTE console? 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
DasIch Posted May 24, 2016 Posted May 24, 2016 Cant believe how fast you answer Here's what i get: _OL_Open: 0 ObjEvent: 0 _OL_FolderAccess: 0
water Posted May 24, 2016 Author Posted May 24, 2016 Re-tested. Works fine here. AutoIt: 3.3.12.0, Windows 7 64 bit, Office 2010 32 bit. What do you run? 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
DasIch Posted May 24, 2016 Posted May 24, 2016 Autoit 3.3.14.2, scite 3.6.2, win 8.1 ent x64, office 2k13 prof+
water Posted May 24, 2016 Author Posted May 24, 2016 (edited) Then you need to run or compile the script for 64bit as well. Means: Add this line at the top of your script. #AutoIt3Wrapper_UseX64=y Edited May 24, 2016 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now