Script to change subject

G

Greg

Hello,

I am looking for an AppleScript that I can call up as part of a rule
to automatically remove a specific phrase from the subject line of
incoming mail.

Basically, my employer recently began using Spam Assassin on the mail
gateway to screen all incoming email. When Spam Assassin detects spam
it adds the phrase "===SPAM===" to the beginning of the subject line.
Spam Assassin manages to catch some spam, but it also marks a lot of
legitimate mail as spam as well. Roughly half of the mail entering my
inbox these days is incorrectly marked as spam.

I currently use SpamSieve to manage my spam locally – with great
success.

What I would like to do is find an AppleScript that I can call up as
part of a Rule to remove the "===SPAM===" from the subject line of
incoming mail. Then I will send the mail through SpamSieve for proper
spam detection.

I have been looking around on the net for a couple of weeks and all I
have been able to find are scripts that allow you to change the
subject of individual messages with a dialog box. These work well, but
I would like something a bit more automated.

If anyone knows of such a script, please point me to it.

Thanks in advance...

greg
 
B

Barry N. Wainwright

Hello,

I am looking for an AppleScript that I can call up as part of a rule
to automatically remove a specific phrase from the subject line of
incoming mail.


greg

Try this. Assuming the marker is placed at the beginning of the subject line
it should work. If the marker is elsewhere, have a go a modifying it!


property subjectText : "===SPAM==="
tell application "Microsoft Entourage"
set theMess to item 1 of (get current messages)
set theSubject to subject of theMess
if theSubject begins with subjectText then
set the subject of theMess to text (length of subjectText) thru -1
of theSubject
end if
end tell
--
Barry Wainwright
Microsoft MVP (see http://mvp.support.microsoft.com for details)
Seen the Entourage FAQ pages? - Check them out:
<http://www.entourage.mvps.org/toc.html>

Please post responses to this newsgroup. If I ask you to contact me
off-list, remove '.INVALID' from email address before replying.
 
G

Guest

Barry,

Thank you very much for the script. It appears to work perfectly and do
the job.

I did do a little modification to your script to deal with a space that
appears after the "===SPAM===" tag that is added to the subject. I am
far from even being a novice scripter, but after a bit of tweaking I
have come up with something that seems to work.

Here is the slightly modified script. Have a look and see if I did it
correctly.

property subjectText : "===SPAM=== "
tell application "Microsoft Entourage"
set theMess to item 1 of (get current messages)
set theSubject to subject of theMess
if theSubject begins with subjectText then
set the subject of theMess to text ((length of subjectText) + 1) thru
-1 of theSubject
end if
end tell

Again thanks for the script. It has removed a fair bit of frustration
from my emailing.

greg

--------------------------
 
Top