Title: Re: Paragraph wrapping with 3 column view

> The real answer to this is "format-flowed"
> mail, which wraps to the window width. For
> my taste, anyhow. And I believe that
> Microsoft MBU has this high on the list of
> desired features.
>
>
>
> Wrapping at other lengths (with hard, rather
> than soft, wrapping) is okay, too.


Paul B. wrote a script for me awhile back that I love...  It takes an incoming message and intelligently removes all the hard line endings (doesn't do short lines in case it's a list of some kind or signature).  I use it all the time for reference emails that I want to save, or even for “emails” that I create with the express purpose of just archiving.  Thanks again, Paul — hard to believe something written for OE 4.5 is still around and working, eh?

**************************************

(* This script will soft-wrap the text of any received plain text message to fill the full  width of its window, while preserving hardwrapping for ends of paragraphs, empty lines, signatures, lines beginning with a space, tab, bullet, < or > including quoted text, and long dashed separator lines.  If you wish to soft-wrap your own sent messages - which OE cannot do, you are asked if you wish to convert the message to an "incoming message" type in order to do the soft wrapping. If you choose to do so, you will not be able to do an automatic "Resend" from the Message menu in future, but otherwise there should be no other consequences. All messages acted upon by the script, whether originally received messages or converted ones, will have an Edit icon in the message pane when they are viewed for the first time following the script's action, and which cannot be removed.

You can select as many, or all, messages as you wish in a folder and run the script on all of them in one go. You will only be asked about the sent message-to-received message conversion once. You can also choose to run this script from a Mail Rule on <all messages> in order to soft-wrap messages as they come in. There is a safety feature built in not to act on messages which are already HTML, and thus are already softwrapped, since the editing process would otherwise turn them into plain text. Similarly it will not act on complex HTML messages (which would turn all the HTML data into text).

Put Soft-Wrap Text script into your effective Script Menu Items folder: in your Microsoft Users Data folder in your Documents folder, if you have one, or your Outlook Express 5 folder if you don't. Then just access it from the Script menu within Outlook Express.

Requirements:  Outlook Express 4.5 / 5.0. --> now works with Entourage

Author: Paul Berkowitz  <[EMAIL PROTECTED]> *)


tell application "Microsoft Entourage"
    
    try
        set goAhead to "check"
        set currMsgs to (get current messages)
    on error
        beep
        display dialog "You must have at least one message selected in the message pane  or be runnning this script from a Mail Rule on incoming messages." buttons "OK" default button "OK" with icon stop
        return
    end try
    
    repeat with theMsg in currMsgs
        
        repeat 1 times
            if theMsg's has html is true then
                exit repeat
            else
                
                try
                    if theMsg = displayed message of front window then
                        set dispMsg to "yes"
                    else
                        set dispMsg to "no"
                    end if
                on error -- no displayed message
                    set dispMsg to "no"
                end try
                
                if class of theMsg ≠ incoming message then
                    
                    if (count of currMsgs) = 1 then
                        beep
                        set dispA to display dialog "The Soft-Wrap Text script only works with received messages." & return & return & "If you wish to convert this Sent Message to an incoming message type in order to soft-wrap its text, click \"Convert\".  You will no longer be able to Resend the message if you do so." buttons {"Convert", "Cancel"} default button "Cancel" with icon caution
                        
                    else
                        if goAhead = "check" then
                            beep
                            set dispA to display dialog "The Soft-Wrap Text script only works with received messages." & return & return & "If you wish to convert all selected Sent Messages to incoming message type in order to soft-wrap their texts, click \"Convert\".  You will no longer be able to Resend the messages if you do so." buttons {"Convert", "Cancel"} default button "Cancel" with icon caution
                        end if
                        
                    end if
                    
                    if button returned of dispA = "Cancel" then error number -128
                    
                    set goAhead to "allClear"
                    
                    if dispMsg = "yes" then
                        set theSubject to subject of theMsg
                        if name of front window = theSubject then -- open in own window
                            set dispMsg to "ownOrig"
                        else -- must be main window
                            set dispMsg to "mainOrig"
                        end if
                    end if
                    
                    set theSource to source of theMsg
                    set theFolder to storage of theMsg
                    
                    set newMsg to make new incoming message at theFolder with properties {source:theSource}
                    delete theMsg
                    set theMsg to newMsg
                    
                    
                end if
                
                set txt to content of theMsg
                
                repeat with i from 1 to (count paragraphs of txt)
                    set aLine to paragraph i of txt
                    
                    repeat while aLine ends with " "
                        try
                            set aLine to text 1 thru -2 of aLine --get rid of extra spaces at end
                        on error -- aLine = " ", no  text -2
                            set aLine to ""
                        end try
                    end repeat
                    if i = 1 then
                        set newTxt to aLine
                    else
                        set preLine to paragraph (i - 1) of txt
                        if aLine is in {"", "-- "} then -- blank line, pre-signature marker
                            set newTxt to newTxt & return -- will add blank line on next line
                        else if {preLine} is in {"", "-- "} or {character 1 of aLine} is in {">", space, tab, "<", "•"} or aLine starts with "----" or aLine starts with "____" or preLine starts with "----" or preLine starts with "____" or ((count characters of preLine) < 45) then -- leave quotes, indents, signatures alone
                            set newTxt to newTxt & return & aLine -- keep wrapped; with preLine return already added, adds blank line with no extras
                        else
                            set newTxt to newTxt & " " & aLine -- unwrap
                        end if
                    end if
                end repeat
                
                set content of theMsg to newTxt
                
                if dispMsg = "yes" then --  received message displayed in main or own
                    get displayed message of front window -- refreshes message window with new softwrapped text
                else if dispMsg = "ownOrig" then -- original sent message was displayed in own window
                    open theMsg
                else if dispMsg = "mainOrig" then -- original sent message was displayed in preview pane
                    set displayed feature of front window to theMsg
                end if
                
            end if
        end repeat --the 1-times repeat
        
    end repeat
    
    
end tell

Reply via email to