Applescript: Shortening long subject lines

G

Gnarlodious

has anyone already written an Applescript that shortens extremely long
subject lines?
For example, I'm receiving emails with Yahoo! Groups formatted subject line
looking like:

Re: [graphicconverterforum] .jpg save action extremely slow

which is so long I can only see 3 letters of the actual subject. Such an
Applescript would remove the bracket-enclosed text from Yahoo! mails.

-- Gnarlie
 
B

Barry N. Wainwright

has anyone already written an Applescript that shortens extremely long
subject lines?
For example, I'm receiving emails with Yahoo! Groups formatted subject line
looking like:

Re: [graphicconverterforum] .jpg save action extremely slow

which is so long I can only see 3 letters of the actual subject. Such an
Applescript would remove the bracket-enclosed text from Yahoo! mails.

-- Gnarlie


This will do it:

tell application "Microsoft Entourage"
set theMess to item 1 of (get current messages)
set theSub to the subject of theMess
if theSub starts with "[" then
set theSub to text ((get offset of "]" in theSub) + 1) thru -1 of
theSub
set the subject of theMess to theSub
end if
end tell

Note: there is no error checking in this script - you need to make sure a
message is open or selected!

This script could be run from a rule as the mail arrives.

--
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

Gnarlodious

Entity Barry N. Wainwright spoke thus:
This script could be run from a rule as the mail arrives.
OK, it won't run from a rule. The script works IF I select a message and run
that particular rule, but won't run if I tell it to run "All rules".

I don't understand how the "Run script" rule works, here's a screenshot of
the project:
http://www.Gnarlodious.com/EntourageSnag.png

What am I doing wrong? Will someone help me with this?

-- Gnarlie
 
P

Paul Berkowitz

Entity Barry N. Wainwright spoke thus:

OK, it won't run from a rule. The script works IF I select a message and run
that particular rule, but won't run if I tell it to run "All rules".

I don't understand how the "Run script" rule works, here's a screenshot of
the project:
http://www.Gnarlodious.com/EntourageSnag.png

What am I doing wrong? Will someone help me with this?

A few possibilities:

When you choose "All Rules" Entourage runs not only your hand-made Mail
rules but also MLM rules - if the messages are in the Inbox which is where
these latter have effect. That will replicate what happens with
automatic-rules-run-on-download. In addition, with messages on download,
they pass through the Junk Mail Filter unless they ere mailing list
messages.

So if any of these messages meet the criteria for any MLM rules, AND you
have not disabled the default "Do not apply other rules" checkbox that's in
Advanced page of every MLM entry, regular rules, including this script run,
will never run on it. Similarly if Junk Filter turns the message to Junk,
and a rule HIGHER in your Rules list moves Junk messages to another folder,
this rule will never run except manually, since rules that move messages
can't be followed by other rules (they always have "Do not apply other
rules..." selected and dimmed.)

Similarly, if these messages meet the criteria for any rule HIGHER in the
Rules list which itself runs a script or moves messages, this rule will
never run except manually, since rules that run scripts or move messages
can't be followed by other rules (they always have "Do not apply other
rules..." selected and dimmed.)

Finally, I see that your script sets the color of messages. Although 'color'
is still a property of 'message' in the AppleScript dictionary, it's
possible that it may not be behaving reliably since 'color' is really
obsolete - it was inherited from OE. But in Entourage we have categories.
Instead of setting a color, you should set a category. To do that, you don't
even need a script, of course, unless you want to _add_ a category, perhaps
at the beginning to set the color. (The message may already have a category
defined by the "apply category of sender" preference.) You can do that by
script:

set theCats to category of theMsg -- may be {}
set category of theMsg to {category "Whatever"} & theCats

That will set the color of theMsg to the color of the category "Whatever".
I'm not saying your script is at fault but, personally, I wouldn't trust the
'color' property of messages.


--
Paul Berkowitz
MVP Entourage
Entourage FAQ Page: <http://www.entourage.mvps.org/toc.html>
AppleScripts for Entourage: <http://macscripter.net/scriptbuilders/>

Please "Reply To Newsgroup" to reply to this message. Emails will be
ignored.

PLEASE always state which version of Entourage you are using - 2001 or X.
It's often impossible to answer your questions otherwise.
 
Top