• 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: Mail Rule Scripts
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mail Rule Scripts


  • Subject: Re: Mail Rule Scripts
  • From: Matthew Smith <email@hidden>
  • Date: Sun, 23 Jan 2011 17:56:06 +1100

On 23/01/2011, at 12:41 , James Roberts wrote:

I want to create a new todo based on a Mail Rule. I have created the rule and made sure it is working (changed background colour). The script compiles and saves fine but when the rule runs no new todo is created. As well as pointing out were I went wrong with my script could you give me an idea on how to debug this sort of thing. The script compiles find, but clearly has a problem, is there a way of stepping through the rule to see were it hiccups?

on perform_mail_action(CreateTodo)
tell application "Mail"
set theSelectedMessages to |SelectedMessages| of CreateTodo
set theRule to |Rule| of CreateTodo
repeat with a from 1 to count theSelectedMessages
set fromMsg to (sender of thisMessage as string)
set subjMsg to (subject of thisMessage as string)
set todoMsg to fromMsg & subjMsg
tell application "iCal"
tell calendar "Mail To Do"
set theDueDate to (current date)
make new todo at end with properties {summary:todoMsg, due date:theDueDate}
end tell
end tell
end repeat
end tell
end perform_mail_action


There are several problems in this script:
1. theRule is not used.
2. The variable a is not used within the repeat loop.
3. thisMessage is used but not set to anything.

Try:
using terms from application "Mail"
on perform mail action with messages messageList
tell application "Mail"
repeat with a from 1 to count of the messageList
set fromMsg to (sender of item a of messageList as string)
set subjMsg to (subject of item a of messageList as string)
set todoMsg to fromMsg & subjMsg
tell application "iCal"
tell calendar "Mail To Do"
set theDueDate to (current date)
make new todo at end with properties {summary:todoMsg, due date:theDueDate}
end tell
end tell
end repeat
end tell
end perform mail action with messages
end using terms from

Matthew Smith
 _______________________________________________
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

  • Follow-Ups:
    • AppleScript Editor's “tell” application pop-up menu (was Re: Mail Rule Scripts)
      • From: Chris Page <email@hidden>
References: 
 >Mail Rule Scripts (From: James Roberts <email@hidden>)

  • Prev by Date: Re: Mail Rule Scripts
  • Next by Date: AppleScript and Simple Finder
  • Previous by thread: Re: Mail Rule Scripts
  • Next by thread: AppleScript Editor's “tell” application pop-up menu (was Re: Mail Rule Scripts)
  • Index(es):
    • Date
    • Thread