The patch by Steve Cunningham seems to be working. I could export a
folder of outgoing and incoming messages. The body with extended ASCII
was correcty translated, but I had some problems with subjectlines with
extended ASCII when importing to PowerMail. The problem may lie with
Powermail and what it expects from the Eudora format. Please let the list
know if you have this problem or others. Please share modifications.

I'm uploading this to Chris' ftp site.

Export - Eudora (patched):

-- written by R Shapiro;  modification of a script by Dan Crevier
on monthString(theMonth)
        if theMonth is January then
                return "Jan"
        else if theMonth is February then
                return "Feb"
        else if theMonth is March then
                return "Mar"
        else if theMonth is April then
                return "Apr"
        else if theMonth is May then
                return "May"
        else if theMonth is June then
                return "Jun"
        else if theMonth is July then
                return "Jul"
        else if theMonth is August then
                return "Aug"
        else if theMonth is September then
                return "Sep"
        else if theMonth is October then
                return "Oct"
        else if theMonth is November then
                return "Nov"
        else if theMonth is December then
                return "Dec"
        end if
end monthString

on dayString(theWeekday)
        if theWeekday is Saturday then
                return "Sat"
        else if theWeekday is Sunday then
                return "Sun"
        else if theWeekday is Monday then
                return "Mon"
        else if theWeekday is Tuesday then
                return "Tue"
        else if theWeekday is Wednesday then
                return "Wed"
        else if theWeekday is Thursday then
                return "Thu"
        else if theWeekday is Friday then
                return "Fri"
        end if
end dayString

on dateHeaderDateHackery(theDate, outFile)
        --   eg  Sat, 19 Apr 1997 13:15:20
        set theWeekday to the weekday of theDate
        set theDay to the day of theDate
        set theMonth to the month of theDate
        set theYear to the year of theDate
        set theTime to the time of theDate
        write dayString(theWeekday) to outFile
        write ", " to outFile
        write (theDay as string) to outFile
        write space to outFile
        write monthString(theMonth) to outFile
        write space to outFile
        write (theYear as string) to outFile
        write space to outFile
        set theMinutes to theTime div 60
        set theHours to theMinutes div 60
        set theMinutes to theMinutes mod 60
        if theHours < 10 then write "0" to outFile
        write (theHours as string) to outFile
        write ":" to outFile
        if theMinutes < 10 then write "0" to outFile
        write (theMinutes as string) to outFile
end dateHeaderDateHackery

on fromLineDateHackery(theDate, outFile)
        --   eg  Sat Apr 19 13:15:50 1997 
        set theWeekday to the weekday of theDate
        set theDay to the day of theDate
        set theMonth to the month of theDate
        set theYear to the year of theDate
        set theTime to the time of theDate
        write dayString(theWeekday) to outFile
        write space to outFile
        write monthString(theMonth) to outFile
        write space to outFile
        write (theDay as string) to outFile
        write space to outFile
        set theMinutes to theTime div 60
        set theSeconds to theMinutes mod 60
        set theHours to theMinutes div 60
        set theMinutes to theMinutes mod 60
        if theHours < 10 then write "0" to outFile
        write (theHours as string) to outFile
        write ":" to outFile
        if theMinutes < 10 then write "0" to outFile
        write (theMinutes as string) to outFile
        write ":" to outFile
        if theSeconds < 10 then write "0" to outFile
        write (theSeconds as string) to outFile
        write space to outFile
        write (theYear as string) to outFile
end fromLineDateHackery

property defaultFromLine : "From [EMAIL PROTECTED] Sat Apr 19 13:15:50 1997" & return

on writeFromLine(theMessage, outFile)
        write "From " to outFile
        -- write senderAddress & " " to outFile
        write "[EMAIL PROTECTED] " to outFile
        tell application "Claris Emailer"
                set theDate to the time sent of theMessage
                my fromLineDateHackery(theDate, outFile)
                -- set senderAddress to the sender of theMessage
                -- set senderAddress to the address of senderAddress
        end tell
        write return to outFile
end writeFromLine

on includeRecipients(theRecipients, theClass, outFile)
        set didOne to false
        tell application "Claris Emailer"
                repeat with theRecipient in theRecipients
                        if the recipient type of theRecipient is theClass then
                                if didOne then write "," to outFile
                                set theAddress to the address of theRecipient
                                set theAddressString to the address of theAddress
                                set theAddressPrettyName to the display name of 
theAddress
                                if theAddressPrettyName is not "" then
                                        write theAddressPrettyName to outFile
                                        write " <" to outFile
                                        write theAddressString to outFile
                                        write ">" to outFile
                                else
                                        write theAddressString to outFile
                                end if
                                set didOne to true
                        end if
                end repeat
        end tell
end includeRecipients


on generateHeaders(theMessage, outFile, isOutgoing)
        tell application "Claris Emailer"
                set theRecipients to the recipients of theMessage
                write "To: " to outFile
                my includeRecipients(theRecipients, to recipient, outFile)
                write return to outFile
                set senderAddress to the sender of theMessage
                
                --! Patch
                --set senderName to the display name of senderAddress
                try
                        set senderName to the display name of senderAddress
                on error errText number errNum
                        if errNum is not -2753 then -- unanticipated error
                                display dialog errText & " (" & errNum & ")"
                                return -1
                        end if
                        set senderName to ""
                end try
                --! end Patch
                
                write "From: " to outFile
                if senderName != "" then
                        write senderName to outFile
                        write " <" to outFile
                        write address of senderAddress to outFile
                        write ">" to outFile
                else
                        --display dialog "sender name is blank"
                        --! Patch
                        --write address of senderAddress to outFile
                        try
                                set senderAddress to the address of senderAddress
                        on error errText number errNum
                                if errNum is not -2753 then -- unanticipated error
                                        display dialog errText & " (" & errNum & ")"
                                        return -1
                                end if
                                set senderAddress to ""
                        end try
                        write senderAddress to outFile
                        --! end Patch
                        
                end if
                write return to outFile
                write "Subject: " to outFile
                -- set theSubject to the subject of theMessage
                -- Crevier says there's a problem here when the subject field gets too 
long
                -- Use the name instead
                set theSubject to the name of theMessage
                write (theSubject as string) to outFile
                write return to outFile
                write "Cc: " to outFile
                my includeRecipients(theRecipients, cc recipient, outFile)
                write return to outFile
                write "Bcc: " to outFile
                my includeRecipients(theRecipients, bcc recipient, outFile)
                write return to outFile
                if isOutgoing then
                        write "X-Attachments: " to outFile
                        write return to outFile
                else
                        write "Date: " to outFile
                        set theDate to the time sent of theMessage
                        my dateHeaderDateHackery(theDate, outFile)
                        write return to outFile
                end if
                write "Message-Id: " to outFile
                write ((the id of theMessage) as string) to outFile
                write return to outFile
        end tell
end generateHeaders

on includeHeaders(theMessage, theHeaders, outFile)
        if theHeaders != "" then
                write theHeaders to outFile
                write return to outFile
        else
                my generateHeaders(theMessage, outFile, false)
        end if
        tell application "Claris Emailer"
                if read status of theMessage is not untouched then
                        write "Status: RO" to outFile
                        write return to outFile
                end if
        end tell
end includeHeaders

on writeTheBody(theMessage, outFile, carefully)
        tell application "Claris Emailer"
                set theBody to content of theMessage
        end tell
        write return to outFile
        if carefully then
                set theLines to the paragraphs of theBody
                repeat with theLine in theLines
                        if theLine starts with "From " then
                                write ">" to outFile
                        end if
                        write theLine to outFile
                        write return to outFile
                end repeat
        else
                write theBody to outFile
        end if
        write return to outFile
end writeTheBody

on writeIncomingMessage(theMessage, outFile)
        tell application "Claris Emailer"
                set theHeaders to long headers of theMessage
        end tell
        -- writeFromLine(theMessage, outFile)
        write defaultFromLine to outFile
        includeHeaders(theMessage, theHeaders, outFile)
        -- if not internet mail, should probably use the careful version
        writeTheBody(theMessage, outFile, theHeaders = "")
end writeIncomingMessage

on writeOutgoingMessage(theMessage, outFile)
        writeFromLine(theMessage, outFile)
        generateHeaders(theMessage, outFile, true)
        writeTheBody(theMessage, outFile, true)
end writeOutgoingMessage


on getOutFile(theName)
        -- set up the output file
        set outFile to choose file name with prompt "Select destination file"
default name theName
        
        -- delete file if it already exists
        try
                tell application "Finder"
                        delete outFile
                end tell
        end try
        
        open for access outFile with write permission
        return outFile
end getOutFile

on done(outFile)
        close access outFile
        tell application "Finder" to set the �class fcrt� of outFile to "CSOm"
end done

on run {}
        tell application "Claris Emailer"
                -- figure out what messages are selected
                set theWindow to the front window
                set windowClass to the class of theWindow
                if windowClass is browser window then
                        set selectedMessages to selection of theWindow
                        set theCount to count of selectedMessages
                        if (theCount) is 0 then
                                display dialog "No messages selected"
                        else
                                if theCount != 1 then
                                        set theFolder to the current folder of 
theWindow
                                        set theName to the name of theFolder
                                else
                                        set theName to the name of item 1 of 
selectedMessages
                                end if
                                set outFile to my getOutFile(theName)
                                -- write the header and body of each message
                                repeat with theMessage in selectedMessages
                                        if the class of theMessage is incoming message 
then
                                                my writeIncomingMessage(theMessage, 
outFile)
                                        else
                                                my writeOutgoingMessage(theMessage, 
outFile)
                                        end if
                                end repeat
                                if theCount = 1 then
                                        display dialog "Message exported" buttons 
{"OK"} default button 1
with icon note
                                else
                                        display dialog (theCount as string) & " 
messages exported" buttons
{"OK"} default button 1 with icon note
                                end if
                                my done(outFile)
                        end if
                else if windowClass is incoming message window then
                        set theMessage to the displayed message of theWindow
                        set outFile to my getOutFile(the name of theMessage)
                        my writeIncomingMessage(theMessage, outFile)
                        display dialog "Message exported" buttons {"OK"} default 
button 1 with
icon note
                        my done(outFile)
                else if windowClass is outgoing message window then
                        set theMessage to the displayed message of theWindow
                        set outFile to my getOutFile(the name of theMessage)
                        my writeOutgoingMessage(theMessage, outFile)
                        display dialog "Message exported" buttons {"OK"} default 
button 1 with
icon note
                        my done(outFile)
                else
                        display dialog "Either a mailbox browser window or a message 
window
must be selected"
                end if
        end tell
end run

___________________________________________________________________________
To unsubscribe send a mail message with a SUBJECT line of "unsubscribe" to
<[EMAIL PROTECTED]>  or  <[EMAIL PROTECTED]>

Reply via email to