You need to copy the “on SearchReplace” handler code into the Entourage script.
Thanks, I’ve done that now. The script finally cleans the subject, but it still doesn’t seem to touch the body. Any ideas? The new script is below. 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 & ((text startChar thru -1 of theLine) as string) & " " --& return
end if
end repeat
set the content of the displayed message 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 "Claris Emailer"
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
