fhanna Posted December 17, 2013 Posted December 17, 2013 Could someone point me in the right direction for finding some simple code to be able to attach to an open email and retrieve the subject line and body text of an email. The user would open the email, launch my application to gather subject line and body text and that is all I need. She would open another email and I would repeat the task after saving the previous data. All postings seem to approach the utilization of folders and email items and I, believe I need help in just capturing the 2 properties of subject and body. Hope I have explained myself and all the hard work gone into this product is commendable but I have searched and overwhelmed by coding that would not be applicable for me. Thanking you in advance.
orbs Posted December 18, 2013 Posted December 18, 2013 with all the power of the OutlookEx UDF, in this case it is not the best tool for the job. if you say that the message window is already open (by the user) when the script launch, then use plain ol' controls management. the point is you use the AutoIt Window Info tool to locate the controls you need to read, then you read them. i've done something like this in the past, give me a few minutes to hunt it down. Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff
orbs Posted December 18, 2013 Posted December 18, 2013 here goes: compile this to exe, launch it, open an Outlook message, hit Ctrl+F12. tested on Outlook 2010. modify the output part as you wish. ; when you will hit Ctrl+F12 the Main() function will be called HotKeySet('^{F12}','Main') ; meanwhile the script just does nothing, waiting in the background for Ctrl+F12 ; you can exit the script from the tray menu While True WEnd Func Main() ; find the currently open window $sMsgWinTitle=WinGetTitle("[active]") ; parse the subject from the window title (remove the last hypen and beyond) $sMsgSubject=StringLeft($sMsgWinTitle,StringInStr($sMsgWinTitle,' - ',Default,-1)) ; get the body - ControlGetText won't do it here If ControlFocus($sMsgWinTitle,'','_WwG1') Then ; this is probably an Outlook message window Send('^a^c') $sMsgBody=ClipGet() MsgBox(0,$sMsgSubject,$sMsgBody) ; output - change this to whatever you wish to do with the output. Else ; this is probably NOT an Outlook message window MsgBox(0,$sMsgSubject,'probably not an Outlook message window.') EndIf EndFunc Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff
fhanna Posted December 18, 2013 Author Posted December 18, 2013 Thank you very much. This was exactly what I was looking for. I was extracting the data by utilzing the View Source capability but that was giving me the HTML code as opposed to text. It is refreshing to have support such as yourself as I was focused on the UDFs and trying to dig thur it. Thank you again.
water Posted December 19, 2013 Posted December 19, 2013 It could be done using COM as well. The UDF does not provide a function to work with the active (displayed) item at the moment. But you could easily retrieve the object of the active item yourself and then use functions of the UDF and pass the items object. I'm on vacation at the moment, but if you have furhter questions I will be happy to help as soon as I have returned. 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 December 29, 2013 Posted December 29, 2013 To retrieve the object of the currently displayed (active) item you could use the following code snippet: $oItem = $oOutlook.ActiveInspector.CurrentItem The item could then be processed using functions of the OutlookEX UDF or your own code. 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