Re: iCal scripting problem
Re: iCal scripting problem
- Subject: Re: iCal scripting problem
- From: Christian Boyce <email@hidden>
- Date: Sun, 3 Oct 2004 19:52:34 -0700
Paul Robinson wrote:
Since presumably you will identify the event by searching for an event
that has the current date as the start date +/- the offset for the
alarm, it's worth pointing out there is a problem with spotting events
that are reoccurring by this method - as well as being very slow for a
large number of events. The start date for reoccurring events is the
start date of the first ever occurrence, not the next future event.
Makes it hard to spot these when searching by start dates.
Oh man. That changes everything. I was indeed doing exactly what you
describe.
Here is a suggestion. It may not be appropriate for what you are trying
to do. When you select email as the action of the alarm, you are given
the option of sending email to yourself only. Makes it useless for
sending mail to others.
Not quite. What actually happens for "email me" alarms, is that iCal
sends a message to your email client via Applescript, when the alarm is
triggered. The Applescript is kept at
'/Applications/iCal.app/Contents/Resources/Mail.scpt' and in that
script, it is the 'on send_mail_sbr' handler that is called. Note that
the event title is actually passed by iCal to the handler. There is
nothing to prevent you adding your own code to the handler, calling
back to iCal, looking for the event with the same title. Assuming that
event titles are unique, this will allow you to identify which event
has been triggered more quickly, even if it is reoccurring.
Very nice. I've experimented with this script and it works perfectly--
but only when iCal is running! When iCal is not running, my modified
script is not called at all. Instead, somehow, the original script--
the one that makes messages that say "Alarm - (event name)"-- is
called, and I can't find it!
At least it's not called twice.
(there are other handlers in that "Mail.scpt" script, and some other
scripts in the iCal package. Sort of interesting to snoop around in
there. Unfortunately I didn't find the script that is being called when
an alarm comes up while iCal is not running.)
To maintain the original function of the menu option, and allow you to
send mail to anybody, just add a dummy email address to your "me" card
in Address Book. This email address could be say "email@hidden."
When you next run iCal, you can select this as an option in the alarm
menu. Then put code in the handler that scans the "myrecipient"
variable, and if it's equal to the dummy email, gets all the relevant
email addresses from the event in iCal, and alters "myrecipient" to a
list of all recipients before using the existing code to send email.
Very nice again. I made good use of this but again it only works when
iCal is running. If it isn't running, none of my code is executed.
Instead, the stock "Alarm - (event name)" messages are generated, and
to use your example they would be addressed to "email@hidden." My
code that looks for that dummy address is completely skipped. There
must be another script somewhere that is called by iCalHelper.
But where?
--
cb
--
Christian Boyce
Macintosh Consultant to the Stars
Christian Boyce and Associates
400 S. Beverly Drive, Suite 214
Beverly Hills, CA 90212
(310) 452-3720
http://www.christianboyce.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden