Hi,
I’m a newbie scripter and trying to figure out how to remove the words FWD:, RE:, REMINDER: from the subject line of Mac Mail messages. Here is some script I modified off the web, which does not seem to do anything. Can anyone of you geniuses help me to debug this script? Thanks.
– Process inbound mail and automatically remove prefixes like FWD: and Reminder:
using terms from application “Mail”
-- Trims "FWD: FW: RE: Reminder:" from the beginning of the subject
on trimSubject(theSubject)
try
set myList to {"Reminder"}
set AppleScript's text item delimiters to ":"
set MyPrefix to item 1 of theSubject's text items
if MyPrefix is in myList then
set MyResult to text ((offset of ":" in theSubject) + 1) thru -1 of theSubject
else
set MyResult to theSubject
end if
-- trim leading/trailing spaces
set MyResult to my trimSpaces(MyResult)
on error
set MyResult to theSubject
end try
-- Restore delimiters to default value
set AppleScript's text item delimiters to {""}
return MyResult
end trimSubject
-- Main loop to process multiple messages
on perform mail action with messages theMessages
try
set theMessageCount to count of theMessages
repeat with theMessageIndex from 1 to theMessageCount
my processMessage(item theMessageIndex of theMessages)
end repeat
end try
end perform mail action with messages
end using terms from