devilburnz Posted February 10, 2020 Posted February 10, 2020 Hi guys, is there any codes or synax to get the mail body and subject from the outlook panel? meaning i can choose a specific email in my outlook mailbox and by 1 single click without opening it, i am able to capture the mail body and subject(outlook panel preview). Any experts advise? Thanks!
water Posted February 10, 2020 Posted February 10, 2020 (edited) Please have a look at my OutlookEX UDF (for download please see my signature). Example script: #include <OutlookEX.au3> Local $iAttachmentCount = 0, $sAttachmentNames = "" Global $oOutlook = _OL_Open() MsgBox(0, "Select", "Please select one or multiple items ...") Global $oSelection = $oOutlook.ActiveExplorer().Selection For $oSel In $oSelection $iAttachmentCount = $oSel.attachments.Count $sAttachmentNames = "" $aAttachments = _OL_ItemAttachmentGet($oOutlook, $oSel) MsgBox(0, "_OL_ItemAttachmentGet", "@error = " & @error & ", @extended = " & @extended) _ArrayDisplay($aAttachments) If $iAttachmentCount > 0 Then For $i = 1 To $aAttachments[0][0] $sAttachmentNames = $aAttachments[$i][2] & @CRLF Next EndIf MsgBox(0, "Selection", "Subject: " & @CRLF & StringLeft($oSel.Subject, 100) & @CRLF & @CRLF & "Body:" & @CRLF & StringLeft($oSel.Body, 100) & @CRLF & @CRLF & "Attachments: " & $iAttachmentCount & @CRLF & $sAttachmentNames) Next Edited February 12, 2020 by water MarkIT, Marc and Skysnake 2 1 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
devilburnz Posted February 10, 2020 Author Posted February 10, 2020 Thanks water, it works like a charm. does the activeexplorer function support attachment? i tried it seems invaild. the code should able to accept no error for no email attachment and if there is 1 or more attachments, it show able to print in messagebox according to the no.ofattachments.
water Posted February 10, 2020 Posted February 10, 2020 Sure, attachments can be accessed. I have updated my example code above (and stripped down subject and body to 100 characters). Adding a print button needs to create a GUI as MsgBox can't be extended in this way. 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
devilburnz Posted February 10, 2020 Author Posted February 10, 2020 saw the message box print the count of the attachments. is there a way to print the attachment names instead?
water Posted February 10, 2020 Posted February 10, 2020 Updated again. 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
Moderators JLogan3o13 Posted February 10, 2020 Moderators Posted February 10, 2020 (edited) Moved to the appropriate forum, as the AutoIt Example Scripts forum very clearly states: Quote Share your cool AutoIt scripts, UDFs and applications with others. Do not post general support questions here, instead use the AutoIt Help and Support forums. Expand Moderation Team Edited February 10, 2020 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!
devilburnz Posted February 11, 2020 Author Posted February 11, 2020 Thanks water for the help. i used your codes, however, i not able to get the attachnames display in the msgbox. any advise? 😮
water Posted February 11, 2020 Posted February 11, 2020 Function _OL_ItemAttachmentGet returns (according to the help file OutlookEx.htm): Quote ; |1 - DisplayName: String representing the name, which does not need to be the actual file name, displayed below the icon representing the embedded attachment ; |2 - FileName: String representing the file name of the attachment ; |3 - PathName: String representing the full path to the linked attached file Expand So if you replace $sAttachmentNames = $aAttachments[$i][2] & @CRLF with $sAttachmentNames = $aAttachments[$i][1] & @CRLF you should get the name displayed in the mail. 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
devilburnz Posted February 11, 2020 Author Posted February 11, 2020 hi water. i still not able to get the $attachmentnames display in the msgbox. i tried [1], [2] and [3]. hmmm
water Posted February 11, 2020 Posted February 11, 2020 I modified the script again. You now get an array with a list of attachments. Can you please post a screenshot of this array? 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
devilburnz Posted February 12, 2020 Author Posted February 12, 2020 i have added the arraydisplay function. the list did not appear.
water Posted February 12, 2020 Posted February 12, 2020 Modified the script again. You now should get an error message from _OL_ItemAttachmentGet. 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
devilburnz Posted February 12, 2020 Author Posted February 12, 2020 i have tried again. the arraydisplay did not pop out. only the msg box without the attachmentname ... hmm
water Posted February 12, 2020 Posted February 12, 2020 Strange - somehow my last modification of the script in post #2 got lost. Could you please grab the script again and run? You should get a MsgBox. 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
devilburnz Posted February 13, 2020 Author Posted February 13, 2020 yup i run it, the msg box error @error = 3, @extended = 0 hmmm..
water Posted February 13, 2020 Posted February 13, 2020 Did you have a look at the help file (OutlookEx.htm)? There you'll find the explanation of the error code. 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
devilburnz Posted February 14, 2020 Author Posted February 14, 2020 hmm i was trying to search for the error in the help file, unfortunately, i could not find files start with OL, outlook,outlookEx etc. Hence, i not able to provide the error explanation. any advise?
water Posted February 14, 2020 Posted February 14, 2020 The OutlookEX.zip file you downloaded contains an OutlookEX.htm file. This file holds the header for each function - including the error codes and their description. 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
devilburnz Posted February 17, 2020 Author Posted February 17, 2020 (edited) Thanks water. Prior to my edited post, i have modify the codes successfully!! Edited February 17, 2020 by devilburnz done
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