Exit Posted October 27, 2013 Share Posted October 27, 2013 I want to call an Autoit exe in a filter rule of Outlook. The following script is called on every new email in my inbox. But there is a problem: I don't know how to identify the current mail id. #include <OutlookEX.au3> $oOL = _OL_Open() $CurentMailItem = $oOL.current.Id ; <<===== How to determine current Mail Item ??? $subject = $CurentMailItem.subject $rc = _OL_Close($oOL) MsgBox(0, "Current Mail Item ", "Subject is: " & $subject, 100) Can someone point me in the right direction ? App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
water Posted October 27, 2013 Share Posted October 27, 2013 I too haven't found a way to retrieve the Id when calling an Exe by a rule. But you can process every new mail by using events. Example script _OL_Example_NewMail_Event.au3 shows how it works. 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 Link to comment Share on other sites More sharing options...
Solution Exit Posted October 31, 2013 Author Solution Share Posted October 31, 2013 (edited) I solved the problem by using a script to call my EXE with the entryid as parameter. At first, create a VBA script by using Alt-F11 in Outlook:Sub OutlookFilter(Item As Outlook.MailItem) x = Shell(Environ("USERPROFILE") & "\Data\Autoit\OutlookFilter.exe " & Item.EntryID, vbHide) End SubDefine a Outlook rule to call the script. Create the EXE. Here a sample.#include <OutlookEX.au3> #include <Array.au3> $oOL = _OL_Open() $EntryId = $cmdlineraw $Item = _OL_ItemGet($oOL, $EntryId) ;_ArrayDisplay($item) ; uncomment for debugging $Body = $Item[9][1] $SentOn = $Item[70][1] $SenderEmailAddress = $Item[64][1] $Subject = $Item[74][1] ;Beep(1000, 100) ; uncomment for debugging Select Case $Body = "" ; empty body is probable spam $rc = _OL_ItemMove($oOL, $EntryId, Default, "Persönliche Ordner\Junk-E-Mail\NoBody") Case $SentOn = "45010101000000" ; no sent date is probable spam ;$rc = _OL_ItemDelete($oOL, $EntryId) ; change MOVE to DELETE if you want no check $rc = _OL_ItemMove($oOL, $EntryId, Default, "Persönliche Ordner\Junk-E-Mail\NoSent") Case StringRegExp($Subject, "*** GMX Spamverdacht ***") ; Classified as spam by GMX $rc = _OL_ItemMove($oOL, $EntryId, Default, "Persönliche Ordner\Junk-E-Mail\*** GMX Spamverdacht ***") Case StringRegExp($SenderEmailAddress, "@firstentry@" & _ "|news@aldi-sued.de" & _ "|@anywhere.com" & _ "|@lastentry@") ; put advertisung in a separate folder $rc = _OL_ItemMove($oOL, $EntryId, Default, "Persönliche Ordner\Posteingang\Werbung") EndSelect _OL_Close($oOL)Don't forget to create the destination folders Hope, this helps others to code Outlook rules in Autoit. Edited October 31, 2013 by Exit App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
water Posted October 31, 2013 Share Posted October 31, 2013 Thanks for sharing Exit 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 Link to comment Share on other sites More sharing options...
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