Sign in to follow this  
Followers 0
fhanna

OutlookEx UDFs and Outlook email properties

6 posts in this topic

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.

Share this post


Link to post
Share on other sites



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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0