• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
RE: Applescript for Rules in Mail
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Applescript for Rules in Mail


  • Subject: RE: Applescript for Rules in Mail
  • From: Adam Morris <email@hidden>
  • Date: Tue, 1 Sep 2009 09:57:54 +0700

Could someone tell me or show me how to write a script that will take  
the email that is sent me from the sql
database ...

This part is actually a lot harder to do than it seems, because there is a bug involved in Leopard Mail (with the threads in Snow Leopard getting an overhaul I wonder if it's been fixed?).

What you have to do is attach the following script to Mail's Rules (in preferences):

property scrambleit : "Scramble It"

using terms from application "Mail"
on perform mail action with messages these_messages for rule this_rule
tell application scrambleit to launch
end perform mail action with messages
end using terms from

Notice what it does is launches a new program. (This gets around the thread issue.)

The program that you launch is actually an Automator Action, which does the following Applescript upon launch:

on run
tell application "Mail"
try
set thesemessages to every message of mailbox "INBOX" of account "Word Scrambler" whose read status is false


repeat with thismessage in thesemessages
set read status of thismessage to true


set replyto to reply to of thismessage
set originalsubject to subject of thismessage
set thewords to content of thismessage


my handle_mail_rule(replyto, originalsubject, thewords) --(sender, subject, message)



end repeat


on error msg number num
display dialog msg & " Error number: "
end try
end tell
end run

Depending on your needs, you could also use the line

set thesemessages to every message of mailbox "INBOX" of ccount "Your Account" whose sender contains "email@hidden"

But be careful with this as you'll have to delete each message (after processing), which can be messy if you're not VERY careful

...and put it in a new email and allow me to attach in the body  
of the email the information they have
requested.

This bit is easy (unless you need rtf or html, which is actually a lot more difficult).

tell application "Mail"
set outgoingMessage to make new outgoing message with properties {visible:true, sender:"email@hidden", subject:"Your Information", content:"hello world"}
end tell

If you want to attach a document instead you would have to add the lines:

tell outemail 
tell content 
make new attachment with properties {file name:temppdffile & originalsubject & ".pdf" as alias} at after last paragraph
end tell
end tell
e
end
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Prev by Date: Mac OS X 10.6 Snow Leopard security changes for scripting additions (was Re: Beeping Beeper)
  • Next by Date: Re: Snow Leopard AppleScript Release Notes
  • Previous by thread: Applescript for Rules in Mail
  • Next by thread: I would appreciate help with this one.
  • Index(es):
    • Date
    • Thread