Re: Mail scripting
Re: Mail scripting
- Subject: Re: Mail scripting
- From: John Delacour <email@hidden>
- Date: Wed, 13 Aug 2003 21:18:02 +0100
Here is a script that will create a rule and a script for it to call.
It works fine here EXCEPT that I have to enable the rule manually
after creating it.
The rule will open any message whose body contains xxxx in a BBEdit window.
Use the script AS IT IS or just change the expression:xxxx bit.
If you have any problems with the script I'll be interested only in
detailed accounts of errors you get. I will not answer questions
from people who have not given any thought to the thing. It works
fine here. If it doesn't work for you, work out why for yourself.
JD
set _rulename to "junk_rule"
set _mailscripts to "" & (path to "cusr") & "Library:Scripts:Mail Scripts:"
set _scriptpath to _mailscripts & "junk_rule_script"
set fU to POSIX path of _scriptpath
tell application "Mail"
(* M A K E T H E F I L T E R *)
if exists rule _rulename then
delete rule _rulename
end if
set _rule to make rule with properties {name:_rulename, enabled:true}
set _pos to a reference to beginning of _rule
set run script of _rule to fU
(* C O N F I G U R E T H E F I L T E R *)
set p to {rule type:message content}
set p to p & {qualifier:does contain value}
set p to p & {expression:"xxxx"}
set _rc to make rule condition at _pos with properties p
end tell
(* P R E P A R E T H E S C R I P T *)
script junk_rule_script
property BBEdit : ""
using terms from application "Mail"
on perform mail action with messages ls
if BBEdit is "" then
tell application "Finder"
name of application file id "R*ch"
set BBEdit to space & quoted form of result & space
end tell
end if
repeat with msg in ls
set {s, i} to {source, message id} of msg
set fU to "/tmp/" & i
set f to POSIX file fU
open for access f with write permission
write s to f
close access f
do shell script "open -a" & BBEdit & quoted form of fU
end repeat
end perform mail action with messages
end using terms from
end script
(* S A V E T H E S C R I P T *)
store script junk_rule_script in file _scriptpath with replacing
.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.