Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Applescript / Mail.app question

Applescript / Mail.app question
Thread Tools
Junior Member
Join Date: May 2002
Status: Offline
Reply With Quote
Dec 6, 2002, 10:17 PM
 
How can I trigger an applescript to run whenever I receive a message in a specific account?
     
Mac Elite
Join Date: Mar 2001
Location: Provo, UT
Status: Offline
Reply With Quote
Dec 7, 2002, 04:28 AM
 
I don't think there is a way to trigger Applescripts with Mail.app. I know that folder triggers were only added to the Finder with OSX 10.2. (Called Folder Actions) So hopefully this will be something added soon to Mail.app.

Probably what you'd have to do is have some Applescript that checks your mailboxes for new mail and then runs an other Applescript when there is new mail. But that's not the ideal situation.

Depending upon what you want to do, you may be able to do it by having a shell script check your pop server just prior to Mail doing it. You can then filter your mail on the pop server using this shell script. Shell scripts can call Applescript. However, depending upon what you want to do though this can be tricky.

For some software that does this to implement something like Mail's spam filter see the following:

http://e-scribe.com/osx/mailfilter/

Note that most of these programs don't work that well as they are little more than regular expressions. Mail uses I believe a Bayesian inferrence program. There are those available if you need them though.


Obviously to use this to trigger an Applescript as opposed to simply deleting the message you'd have to modify the source somewhat.
     
Mac Elite
Join Date: Mar 2001
Location: Provo, UT
Status: Offline
Reply With Quote
Dec 7, 2002, 04:43 AM
 
Oh, one other thought. If you just want to be able to send mail to trigger some applescript rather than use it to organize your MAil app, there is a solution.

Albert allows you to take actions on incoming mail. All it actually consists of is a simple Pop checker that then runs an application when a particular pattern occurs in the subject. Further it is actually a RealBasic application instead of a nice clean C program. C'est la vie. It might fit your needs.

http://www.versiontracker.com/morein...129&db=mac


I should add that I find it odd that Mail can't run scripts since Claris Emailer could way back in the pre-OSX days. It seems to me that this would be a very good thing to add to either folders or rules. Perhaps if enough people go to the OSX suggestion page over on Apple's home page?

If you really need this feature I believe that BareBone's MailSmith mail program provides it. Further most scripts written for BBEdit purportedly work on it.
(Last edited by clarkgoble; Dec 7, 2002 at 05:10 AM. )
     
patzoul  (op)
Junior Member
Join Date: May 2002
Status: Offline
Reply With Quote
Dec 7, 2002, 06:39 PM
 
Thanks for all this info.
     
Mac Elite
Join Date: Mar 2001
Location: Provo, UT
Status: Offline
Reply With Quote
Dec 13, 2002, 07:49 PM
 
One other solution I just thought of while working on something else is to create a folder action Applescript. These are triggers for Applescripts that occur when something in a folder changes. I've not played with them much, but I know they are very powerful and work even when files are changed by applications or by the Terminal.

The folder with the mailboxes for Mail is ~/Library/Mail/Mailboxes. There is also a separeate inbox for each account. i.e. for my pop account it is in ~/Library/Mail/POP-clark.goble@clark.goble@attbi.com.

That obviously keeps you from doing a nice generic Applescript, but you can do it.

After your Applescript has triggered you can iterate through the mailboxes by scripting Mail to see what new messages are present and act accordingly.
     
Mac Elite
Join Date: Mar 2001
Location: Provo, UT
Status: Offline
Reply With Quote
Dec 14, 2002, 03:55 PM
 
.
     
Mac Elite
Join Date: May 1999
Location: San Jose, CA
Status: Offline
Reply With Quote
Dec 14, 2002, 04:14 PM
 
Originally posted by patzoul:
How can I trigger an applescript to run whenever I receive a message in a specific account?
Mail.app has one of the weakest AppleScript integrations of ANY Mac OS X email client.

If you're serious about AppleScript and email, you need Entourage or Eudora.

It's ironic that a Microsoft app implements Apple's technologies better than Apple themselves. Apple should be ashamed.
Gods don't kill people - people with Gods kill people.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 06:27 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2