Save the contents of a message to a file.

From: David Smith (gveloper_at_ncisnet.net)
Date: 06/04/04


Date: Fri, 04 Jun 2004 01:29:18 -0400

I really don't know if this is more an entourage question or an applescript
question, but I'm having difficulty with what I thought would be a simple
scripting project. I receive emails that I would like to create a rule for
that would run an applescript that would copy the text of the message to a
plain text file on my local hard drive. From there another shell script will
pick it up and go from there, but the data has to be in plain text. Right
now I have the following script:

-----------------------------------------------
tell application "Microsoft Entourage"
    set theMsgs to (current messages)
    repeat with theMsg in theMsgs
        set this_data to theMsg's {content}
    end repeat
    
end tell
try
    
    set this_file to ((("Macintosh HD:Users:gVeloper:Desktop:") as text) &
"MessageText")
    my write_to_file(this_data, this_file, false)
    
    
on error error_message number error_number
    set this_error to "Error: " & error_number & ". " & ¬
        error_message & return
    set the log_file to (("Macintosh HD:Users:gVeloper:Desktop:") as text) &
"Script Error Log"
    my write_to_file(this_error, log_file, true)
end try

on write_to_file(this_data, target_file, append_data)
    try
        set the target_file to the target_file as text
        set the open_target_file to ¬
            open for access file target_file with write permission
        if append_data is false then ¬
            set eof of the open_target_file to 0
        write this_data to the open_target_file starting at eof
        close access the open_target_file
        return true
    on error
        try
            close access file target_file
        end try
        return false
    end try
end write_to_file
-----------------------------------------------

The problem is that the resulting file is not in plain text, but something I
cannot edit in vi and can't use my unix utilities to manipulate. I've gone
through entourage's dictionary and it seems like the "content" property is
what I want, but how can I write it to plain text?

Thanks in advance,

--
Dave
gveloper@ncisnet.net        gveloper@mac.com
http://homepage.mac.com/gveloper/
http://ncisnet.net
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GAT d? s+ a-- C++++ ULIS++++ P+ L+++ E- W+++ N+ o K- w--- O M++ V-- PS-- PE
Y+ PGP++ t+ 5 X+++ R tv++ b- DI++++ D+ G++ e h-- !r y-
------END GEEK CODE BLOCK------


Relevant Pages

  • Re: Time Machine: Spit!!!
    ... I'd like a script that'd dive down a directory tree recursively and move ... If you want to see an AppleScript version as well then I could knock one up in the next day or so when I have a bit of spare time. ... As for data types - I just develop patiently one small bit at a time and looking carefully at the results. ... Standard way to do recursion in AppleScript is to define a function that calls itself. ...
    (uk.comp.sys.mac)
  • Re: Question for Paul and other AppleScripters
    ... I'm writing a script to do batch edits on my contacts. ... > objects or use a reference to to loop through the list of selected contacts to ... If you want to use AppleScript, ... enable whose clauses on lists. ...
    (microsoft.public.mac.office.entourage)
  • Re: Auto loading applescripts?
    ... That's the biggest lack of AppleScript compared to VBA ... there is currently no mechanism of any type to embed a script inside a ... as there is in Entourage. ... Office macros enabled a whole plethora of viruses, ...
    (microsoft.public.mac.office.word)
  • Re: Command line printing
    ... through an applescript, the following script would work (this is just code ... By the way - command line is not an option. ... so that margin warnings won't stop the script. ... >> Using lpr does not work as I suspect lpr does not understand the WORD>> format. ...
    (microsoft.public.mac.office.word)
  • Re: Applescript vs. Visual Basic speed
    ... If you were to write the "same script" in Visual ... > Basic and in Applescript -- that is, follow the same logic and apply ... It should not make much difference, but might be a little faster as a VBA ... PLEASE always state which version of Microsoft Office you are using - ...
    (microsoft.public.mac.office)

Loading