Title: Request for Script Help
The script below, with small changes, was supplied with the DevonThink application (a database that handles text, RTF, PDF, HTML, and other files and also has a built-in browser for only $35) to import messages from Mail. I’d like to use it to import E’rage VX messages; unfortunately, there is a problem with the term “Headers”. In Mail this is a class; in Entourage V X I cannot find the headers anywhere in the dictionary. The script works fine if I comment out the headers part, except that then it doesn’t import the headers.

Could one of the scripting gurus point me in a direction for how to handle the headers? Thanks!


--    Import selected Mail.app messages to DEVONthink.
--    Developed on Mac OS X 10.2.6 with DEVONthink PE 1.7.1.
--    Stephen D. Poole, [EMAIL PROTECTED]
--    2003-08-28

-- 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 all 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

--
Bruce
____________________________________________________
B R U C E  K.   klutch-at-erols.com

Reply via email to