Title: Re: Your top 5 scripts and add ons
On 10/31/04 11:22 AM, "Sherman Wilcox" <[EMAIL PROTECTED]> wrote:

> I like the idea of the script that someone has (sorry, I forget who) that
> sends a message to DevonThink. Any chance you'd share that with us?

You can get this script on the Devon Technology site, but I'm including it here for your use:
------------------------------------------------------------------------------------------------------
-- ���Import selected Entourage messages to DEVONthink.
-- ���Developed on Mac OS X 10.2.6 with DEVONthink PE 1.7.1.
-- ���by Stephen D. Poole, [EMAIL PROTECTED] 2003-08-28
-- ���Modified for Entourage by
B.ru c-e •K1u-tch-k0 on 12/29/03 on Mac OS 10.3.2 with DEVONthink 1.7.4 with help from David Cortright

-- this string is used when the message subject is empty
property pNoSubjectString : "(no subject)"

-- this is the location where temporary files will be created
property pTemporaryFilePath : "/tmp/"

-- entry point
tell application "Microsoft Entourage"
    set theSelection to the selection
   if the length of theSelection is less than 1 then
       display dialog "One or more messages must be selected."
    end if
   repeat with theMessage in theSelection
       set theFile to my saveMessageFile(theMessage)
        tell application "DEVONthink" to import theFile
       tell me to deleteFile(theFile)
    end repeat
end
tell

-- save the message as a file in the temporary directory
-- its name will be the message subject
on saveMessageFile(theMessage)
    using terms from application "Microsoft Entourage"
        set theSubject to subject of theMessage
       set theHeaders to headers of theMessage
       set theContent to content of theMessage
   end using terms from
   if theSubject is equal to "" then set theSubject to pNoSubjectString
   set theFileName to my makeFileName(theSubject)
    set theFileRef to open for access (POSIX file theFileName) with write permission
   write theHeaders to theFileRef as string
   write theContent to theFileRef as string
   close access theFileRef
   return theFileName
end saveMessageFile

-- clean the filaname and append it to the temporary path
on makeFileName(baseName)
    set baseName to my cleanFileName(baseName)
    set theName to pTemporaryFilePath & baseName
   return theName
end makeFileName

-- get rid of problematic characters in the filename
-- todo - should probably also truncate if necessary
on cleanFileName(theName)
    set cleanedName to ""
    repeat with theChar in every character of theName
       if (theChar as string = "/" or theChar as string = ":") then set theChar to "-"
        set cleanedName to cleanedName & theChar
   end repeat
   return cleanedName
end cleanFileName

-- delete the specific file (POSIX)
on deleteFile(theFile)
    -- can't find a standard extension to delete a file, so this unfortunately requires Finder
   tell application "Finder" to delete (POSIX file theFile) as string
end deleteFile




--
B-r-u -c-e

Reply via email to