Title: Reply to list from digest [SCRIPT]
I realized that my script "In Digest to List" that I uploaded to my web site (URL below) recently calls for the "textSoap" scripting addition, which people have to pay for. Rather than make this script unusable to many or too costly for an uncommon function, I've rewritten a part of the script that was using textSoap (a great text-cleaning shareware utility, BTW, free plug, comes with scripting addition to give access to all its functions from scripts) to now require NO SCRIPTING ADDITIONS except Standard Additions.
Please note that I cannot claim credit for originating this script. It comes from Claris Emailer days; I’ve lost track of who the original author was. I’ve tinkered with it and made it work with Entourage, that’s all.
Here is the revised script. To use it:
1. Copy and paste into Script Editor.
2. Save it as compiled script into "Documents>Microsoft User Data>Entourage Script Menu Items" folder.
3. Open a digest message in Entourage, and select the complete text of the message you want to reply to, including the date and subject (you can end the selection at any point in the text, but you must include the header info).
4. Select the script from the script menu.
-- routine to do a search and replace on text
to gblReplace of mainString from stringA by stringB
set od to AppleScript's text item delimiters
set AppleScript's text item delimiters to stringA
set temp to every text item of mainString
set AppleScript's text item delimiters to stringB
set mainString to temp as text
set AppleScript's text item delimiters to od
return mainString
end gblReplace
on replyText(theText)
set theReplyText to ""
-- set theText to textSOAP "Spaces" on theText
repeat while theText contains " "
set theText to gblReplace of theText from " " by " "
end repeat
set theLines to the paragraphs of theText
set blank to false
set looking to true
repeat with theLine in theLines
if looking then
if the length of theLine = 0 then set looking to false
else
if theLine starts with "-- " and the length of theLine is 3 then exit repeat
if blank then set theReplyText to theReplyText & ">" & return
set blank to false
if the length of theLine is 0 then
set blank to true
else if theLine starts with ">" then
set theReplyText to theReplyText & ">" & theLine & return
else
set theReplyText to theReplyText & "> " & theLine & return
end if
end if
end repeat
return theReplyText
end replyText
on getHeader(theText, theHeader)
set theLines to the paragraphs of theText
repeat with theLine in theLines
-- set theLine to textSOAP "Spaces" on theLine
repeat while theLine contains " "
set theLine to gblReplace of theLine from " " by " "
end repeat
if theLine starts with theHeader then
set theSubject to characters (2 + the (length of theHeader)) thru -1 of theLine as string
return theSubject
end if
end repeat
return ""
end getHeader
on makeRecipient(theMessage)
tell application "Microsoft Entourage"
set theHeaders to the headers of theMessage
repeat with theHeader in the paragraphs of theHeaders
if theHeader starts with "Reply-To:" then
set theRecipient to characters 11 thru -1 of theHeader as string
return theRecipient
end if
end repeat
return ""
end tell
end makeRecipient
on replyOne(theMessage, theSelectedText)
tell application "Microsoft Entourage"
set theText to my replyText(theSelectedText)
set theSubject to my getHeader(theSelectedText, "Subject:")
if theSubject does not start with "Re: " then set theSubject to "re: " & theSubject
set theRecipient to my makeRecipient(theMessage)
if theRecipient is "" then
set theAddress to the sender of theMessage
set theAddressString to the address of theAddress
set theName to the display name of theAddress
if theName is "" then
set theRecipient to theAddressString
else
set theRecipient to "\"" & theName & "\" <" & theAddressString & ">"
end if
end if
set theDate to my getHeader(theSelectedText, "Date:")
set theAuthor to my getHeader(theSelectedText, "From:")
set theAttribution to ""
if the length of theDate = 0 then
if the length of theAuthor � 0 then
-- From: but no Date:
set theAttribution to (theAuthor & " wrote:" & return)
else
-- neither From: nor Date:
set theAttribition to ""
end if
else
if the length of theAuthor = 0 then
-- Date: but no From:
set theAttribution to ("On " & theDate & ", " & " someone wrote:" & return)
else
-- Date: and From:
set theAttribution to ("On " & theDate & ", " & theAuthor & " wrote:" & return)
end if
end if
set theText to theAttribution & return & theText
set the replied to of theMessage to true
try
set theAccount to the account of theMessage
if default signature type of theAccount is not none then
make new draft window with properties ¬
{subject:theSubject, content:theText, to recipients:theRecipient, account:theAccount, other signature choice:default signature choice of theAccount}
else
make new draft window with properties ¬
{subject:theSubject, content:theText, to recipients:theRecipient, account:theAccount}
end if
on error
if default signature type of theAccount is not none then
make new draft window with properties ¬
{subject:theSubject, content:theText, to recipients:theRecipient, other signature choice:default signature choice of theAccount}
else
make new draft window with properties ¬
{subject:theSubject, content:theText, to recipients:theRecipient}
end if
end try
end tell
end replyOne
on run
tell application "Microsoft Entourage"
set theMessages to the current messages
set theSelection to the selection of the front window
if the (count of theMessages) = 1 and the class of theSelection is string then
set theMessage to item 1 of theMessages
my replyOne(theMessage, theSelection)
else
display dialog "Text in a single message must be selected." buttons {"OK"} default button {"OK"}
end if
end tell
end run
--
Peace,
Allen Watson <[EMAIL PROTECTED]> XNS name: =Allen Watson
A Mac family since 1984 <http://home.earthlink.net/~allenwatson/>
Applescripts for Outlook Express and Entourage: <http://homepage.mac.com/allenwatson/>
- re: Reply to list from digest [SCRIPT] Allen Watson
- re: Reply to list from digest [SCRIPT] William Howarth
- re: Reply to list from digest [SCRIPT] chris stearns
