Title: Script to fix mbx files created by Entourage
Fix mbx file -- By Allen Watson
<[EMAIL PROTECTED]>
Monday, November 13, 2000

BRIEF DESCRIPTION: Fixes Eudora-type mailbox files created by dragging a folder to the desktop so that they can actually be used by Eudora.

Entourage has a terrific ability to help you create a Unix/Eudora style mailbox file simply by dragging a folder to your desktop. The contents of the folder are rapidly transformed into a mailbox format file. Eudora, which is also available as a free download, can be used to read and perform extremely rapid searches on these mailbox files, allowing Mac users to have the best of both worlds. It is not an unreasonable thought to use Eudora as the archiving program for Entourage.

Unfortunately there is a glitch (a design flaw rather than a bug) in the way Entourage does this, and the format of the file is not quite right. Eudora cannot read it. The Entourage programming team knows of this problem and assures us it will be fixed in the next release. While waiting for that date, some of us may want a workaround.

Until now, the only alternative was the wonderful AppleScript by R. Shapiro, "Export Eudora". This script will take a set of messages selected in Entourage and export them as a Unix/Eudora mailbox file, much like Entourage is supposed to do by dragging the folder. Because you must select the messages, you can copy just partial folders (but not <multiple> folders; neither method allows that). It also sets the creator type of the file to be a Eudora mailbox, so that you can double-click the file and open it in Eudora. Unfortunately, compared to Entourage's drag and drop method, the script is quite slow.

Enter my new script, "Fix mbx file". It is a single-purpose script whose purpose will cease to exist once Entourage fixes its glitch. Its use? Using the drag and drop method, have Entourage create one or more mailbox files from folders. Then, drag and drop the resulting files on the "Fix mbx file" droplet. The script is very fast, and will fix the formatting error in the file. It will also change the creator type code to Eudora so you can open the files by double-clicking. Bingo! You now have <usable> Eudora mailbox files.

If you wish, you may also double-click the applet. It will prompt you to select some mailbox files to convert, using a standard dialog, and will then do as above.

---- Begin Script ----

on open (someFiles)
    set newDate to "From ???@??? Fri Jun 11 07:59:38 1999"
    repeat with aFile in someFiles
        set x to info for aFile
        set aFile to aFile as alias
        if file type of x is "TEXT" or file type of x is "MBOX" then
            set fileRef to open for access aFile with write permission
            set t to read fileRef
            set t to my SearchReplace(t, "From ^^^@^^^", newDate)
            write t to fileRef starting at 0
            close access fileRef
            my setTypes(aFile)
        end if
    end repeat
end open
on run
    set someFiles to choose file with prompt "Select mbx file to convert." of type {"TEXT", "MBOX"}
    set someFiles to someFiles as list
    set newDate to "From ???@??? Fri Jun 11 07:59:38 1999"
    repeat with aFile in someFiles
        set x to info for aFile
        --        display dialog aFile as text
        set aFile to aFile as alias
        if file type of x is "TEXT" or file type of x is "MBOX" then
            set fileRef to open for access aFile with write permission
            set t to read fileRef
            set t to my SearchReplace(t, "From ^^^@^^^", newDate)
            write t to fileRef starting at 0
            close access fileRef
            my setTypes(aFile)
        end if
    end repeat
end run

on setTypes(aFile)
    tell application "Finder"
        set the creator type of aFile to "CSOm"
        set the file type of aFile to "TEXT"
    end tell
end setTypes
-- routine to do a search and replace on text
on SearchReplace(mainString, searchString, replaceString) -- Parameters: search, replace, the String
    set olddelis to AppleScript's text item delimiters
    
    set AppleScript's text item delimiters to (searchString)
    tell me to set theList to (every text item of mainString)
    
    set AppleScript's text item delimiters to (replaceString)
    set theString to theList as string
    
    set AppleScript's text item delimiters to olddelis
    return theString
end SearchReplace

---- End Script ----
--
Peace,
Allen Watson <[EMAIL PROTECTED]> XNS name: =Allen Watson
A Mac family since 1984
My web page: <http://home.earthlink.net/~allenwatson/>

Reply via email to