Jump to content

OutlookEx UDFs and Outlook email properties


fhanna
 Share

Recommended Posts

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.

Link to comment
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.

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

 

Link to comment
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

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

 

Link to comment
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.

Link to comment
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 2022-02-19 - Version 1.6.1.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 (NEW 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

  • 2 weeks later...

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 2022-02-19 - Version 1.6.1.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 (NEW 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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...