horphi Posted July 13, 2015 Share Posted July 13, 2015 Hello community, nice to be here.i started with autoit it´s amazing what kind of new world is opening with this awesome tool.I have a question regarding Outlook.I want to use AutoIt to look for a string inside the body of the E-Mail.When you try to get an window ID, the grabber shows unfortunately only the whole outlook window without the Email body...How i can grab the Text of the E-Mail to search for a specified value, copy them and insert them into another database?Windows 7 - Outlook 2010Best regards, Phil Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted July 13, 2015 Moderators Share Posted July 13, 2015 (edited) Hi, horphi, welcome to the forum. This pulls up any mail item in the Inbox with "VDI Project" in the subject. You should be able to modify it easily to search the Body of the email. Take a look at the OutlookEX example for _OL_ItemFind for more info.#include <OutlookEX.au3> $oOutlook = _OL_Open() $aMail = _OL_ItemFind($oOutlook, "*\Inbox", $olMail, "[Subject]=VDI Project", "", "", "Subject,Body", "", 1) If IsArray($aMail) Then _ArrayDisplay($aMail) Edited July 13, 2015 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
horphi Posted July 13, 2015 Author Share Posted July 13, 2015 Hi, horphi, welcome to the forum. This pulls up any mail item in the Inbox with "VDI Project" in the subject. You should be able to modify it easily to search the Body of the email. Take a look at the OutlookEX example for _OL_ItemFind for more info.#include <OutlookEX.au3> $oOutlook = _OL_Open() $aMail = _OL_ItemFind($oOutlook, "*\Inbox", $olMail, "[Subject]=VDI Project", "", "", "Subject,Body", "", 1) If IsArray($aMail) Then _ArrayDisplay($aMail) Hello JLogan3o13,thx for the response.I get the array accomplished but he displays always zero, although i copied the exact header....$aItems = _OL_ItemFind($oOutlook, "*\Posteingang", $olMail, "[Subject]=AW: ACS BEschriftung", "", "", "Subject,Body", "", 1) If IsArray($aItems) Then _ArrayDisplay($aItems, "OutlookEX UDF: _OL_ItemFind Example Script - Unread mails") Else MsgBox(48, "OutlookEX UDF: _OL_ItemFind Example Script", "Could not find an unread mail. @error = " & @error & ", @extended: " & @extended) EndIf _OL_Close($oOutlook)BRHorphi Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted July 13, 2015 Moderators Share Posted July 13, 2015 You have your folder pointing to *\Posteingang, which would mean it is Mailbox\Posteingang. Is this path correct, or is it a sub-folder of another folder (Inbox, perhaps?). When I create a posteingang folder in the root directory, and add three mail items with the verbiage you have, the array shows just fine:#include <OutlookEX.au3> $oOutlook = _OL_Open() $aItems = _OL_ItemFind($oOutlook, "*\Posteingang", $olMail, "[Subject]=AW: ACS BEschriftung", "", "", "Subject,Body", "", 1) If IsArray($aItems) Then _ArrayDisplay($aItems, "OutlookEX UDF: _OL_ItemFind Example Script - Unread mails") Else MsgBox(48, "OutlookEX UDF: _OL_ItemFind Example Script", "Could not find an unread mail. @error = " & @error & ", @extended: " & @extended) EndIf horphi 1 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
horphi Posted July 16, 2015 Author Share Posted July 16, 2015 (edited) Hi JLogan3o13,dont ask me why, i changed nothing (i know that´s not true ;-)) but now it fits....Same script on another PC with another subject and the result gives the right statment...Thx for help.Now the next step is to search in the body for some repeating values, who needs to be copied into another software.Can i use the array to say in the next loop: use Col1 and get string"_"?BRHorphi Edited July 16, 2015 by horphi Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted July 16, 2015 Moderators Share Posted July 16, 2015 Yes, you can do a for loop to loop through the array, and do something like:If StringInStr($aItems[$i][1], "My Search Term") Then ;Do Stuff EndIf horphi 1 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
horphi Posted July 19, 2015 Author Share Posted July 19, 2015 Hello again,how can i change the Subject? I want that all E-Mails with the Word "Excel" inside the subject shall be displayed. BRHorphi Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted July 20, 2015 Moderators Share Posted July 20, 2015 Well...You've already been shown that this line searches for the term AW: ACS BEschriftung in the subject line:$aItems = _OL_ItemFind($oOutlook, "*\Posteingang", $olMail, "[Subject]=AW: ACS BEschriftung", "", "", "Subject,Body", "", 1)What do you think you would need to change to get it to look for Excel instead? horphi 1 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
horphi Posted July 22, 2015 Author Share Posted July 22, 2015 Hi JLogan3o13,i want to look for all mails with the subject ACS*....How can i set the wildcard to look for different subjects? BR Horphi Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted July 22, 2015 Moderators Share Posted July 22, 2015 horphi, the line in post #8 shows you how to change the subject. What have you tried on your own, and what is not working? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
horphi Posted July 23, 2015 Author Share Posted July 23, 2015 (edited) HI JLogan3o13,.what i try is to set is"[Subject] = ACS*" and not "[Subject] = ACS BEschriftung"Look for all Items with contain the Word ACS in the Subject. Unfortunallety it fails... BR Edited July 23, 2015 by horphi Link to comment Share on other sites More sharing options...
water Posted July 24, 2015 Share Posted July 24, 2015 Parameter $sRestrict does an exact match whereas parameters $sSearchName and $sSearchValue do a partial match. None of them supports wildcards.So to search for subject with text "ACS" in it try (untested):#include <OutlookEX.au3> $oOutlook = _OL_Open() $aMail = _OL_ItemFind($oOutlook, "*\Inbox", $olMail, "", "Subject", "ACS", "Subject,Body", "", 1) If IsArray($aMail) Then _ArrayDisplay($aMail) 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...
horphi Posted July 25, 2015 Author Share Posted July 25, 2015 Hello Water, i tried already this , but failed unfortunately.It means i need always the complete Text of the subject...?BR Horphi Link to comment Share on other sites More sharing options...
water Posted July 25, 2015 Share Posted July 25, 2015 (edited) Should work because $sSearchName/$sSearchValue uses StringInStr.Can you please post the code you used? Edited August 1, 2015 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 Link to comment Share on other sites More sharing options...
horphi Posted July 27, 2015 Author Share Posted July 27, 2015 (edited) Hello Water, now it works.I using now the _OL_ItemSearch Function. It needs a while to understand, but it works. :-)#include <OutlookEX.au3> #include <Array.au3> #include <String.au3> #include <MsgBoxConstants.au3> Hotkeyset("{F2}", "schliessen") Func schliessen () Exit EndFunc Grab_email() Func Grab_email() Dim $aItems Global $oOutlook = _OL_Open() $StrOutlook_Inbox ="\Inbox" $strsql = "@SQL=urn:schemas:httpmail:subject like '%SearchTerm%'" $aItems=_OL_ItemSearch($oOutlook,$StrOutlook_Inbox,$strsql,"Subject,Body") If IsArray($aItems) Then _ArrayDisplay($aItems, "OutlookEX UDF: _OL_ItemFind Example Script - Unread mails") Else MsgBox(48, "OutlookEX UDF: _OL_ItemFind Example Script", "Could not find an unread mail. @error = " & @error & ", @extended: " & @extended) EndIf _FileWriteLog(@ScriptDir & "CDSN.log", "Got the emails Moving to Processing Stage") EndFuncBR Horphi Edited July 30, 2015 by horphi Link to comment Share on other sites More sharing options...
horphi Posted July 31, 2015 Author Share Posted July 31, 2015 Hi WAter,when you using the ItemSearch, then you get the email body shown in the result? BRHorphi Link to comment Share on other sites More sharing options...
water Posted August 25, 2015 Share Posted August 25, 2015 Sorry for the late reply due to vacation etc.I'm not sure you get the whole body. Maybe just 255 characters. You need to test.If it is an HTML formatted body then it might help to query property HTMLBody. 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