Title: "Clean Forward" script doesn't work anymore
I used to use a script a long time ago called "Clean Forward" (see below) that would take the email and remove excess quoting, cr's, and "Fwd."  It doesn’t work anymore.  The messy original(s) get sent along as attachments.  Can this script be made smart enough to send a clean version of the original message without attaching messy versions?  I would greatly appreciate any assistance.  Thanks in advance,

Neil

tell application "Microsoft Entourage"
    -- ???clean subject
   set theSubject to the subject of the front window
   set theSubject to my SearchReplace(theSubject, " (fwd)", "")
    set theSubject to my SearchReplace(theSubject, "Fw: ", "")
    set theSubject to my SearchReplace(theSubject, "FW: ", "")
    set theSubject to my SearchReplace(theSubject, "Re: ", "")
    set theSubject to my SearchReplace(theSubject, "Fwd[2]:", "")
    set theSubject to my SearchReplace(theSubject, "Fwd:", "")
    
    set the subject of the front window to theSubject
   
    -- ???clean text
   set theText to the content of the front window
   
    -- strip up to return return to get rid of header
   set headerEnd to offset of (return & return) in theText
   set theText to text (headerEnd + 2) thru -1 of theText
   
    -- strip end of forward message
   set theText to my SearchReplace(theText, ¬
        "------ End of Forwarded Message", "")
    
    --while we’re at it, maybe we can get rid of the ad at the bottom of hotmail messages:
   set theText to my SearchReplace(theText, ¬
        "Get more from the Web.  FREE MSN Explorer download : htp://explorer.msn.com", "")
    
    -- strip leading " " and ">"
   set theParagraphs to the paragraphs of theText
   set theNewText to ""
    repeat with theLine in theParagraphs
       set lineLength to length of theLine
       set startChar to 1
        repeat while startChar ? lineLength
           set theChar to character startChar of theLine
           if theChar is not " " and theChar is not ">" then
               exit repeat
           end if
           set startChar to startChar + 1
        end repeat
       if (startChar ? length of theLine) then
           set theNewText to theNewText & return & return
       else
           set theNewText to theNewText & return & (text startChar thru -1 of theLine)
        end if
   end repeat
   
    set the content of the front window to theNewText
end tell
end
run

-- routine to do a search and replace on text
on SearchReplace(mainString, searchString, replaceString) -- Parameters: search, replace, the String
   considering case
       set olddelis to my text item delimiters
       
        set my text item delimiters to (searchString)
        tell me to set thelist to (every text item of mainString)
        
        set my text item delimiters to (replaceString)
        set theString to thelist as string
       
        set my text item delimiters to olddelis
   end considering
   return theString
end SearchReplace

-- make sure a outgoing message window is frontmost
on CheckOutgoing()
    tell application "Microsoft Entourage"
        if the class of the front window is not outgoing message window then
           display dialog "This script is designed to work with an outgoing message window frontmost."
            exit repeat
       end if
   end tell
end
CheckOutgoing

Reply via email to