Moving from Microsoft Office VBA to AppleScript:
MacTech's Guide to Making the Transition
Introduction
|
Table of Contents
Page Prev and Page Next buttons at bottom of the page.
|
April, 2007
Page 132
(In fact, we ought to be able to just get the address property of each recipient of the original message and just make that the content for the new group entry, without even needing to parse it into its own separate address and display name properties, other than for checking for duplication.)
Well, this is a bug in Entourage's AppleScript. When making a new group entry, you have to use that text format of "Joe Blow <jblow@aol.com>", or simply "jblow@aol.com" if there's no display name, rather than the proper record structure for content of {address:"jblow@aol.com", display name:"Joe Blow"}.
This bug has been in place since Entourage existed (and before that in Outlook Express too); at this point if it were fixed it would break too many scripts. So it will never be fixed – you've just got to learn it. It's not documented anywhere but here (it really should be mentioned in the dictionary now that there's no longer any limit on dictionary entry description length, but that's only since OS 10.3, newer than Entourage 2004).
Calendar Events and Tasks
Make New Event / Open an Event or Task
Making a new event (the AppleScript class for what's usually called "calendar event") is just the same as making a new contact, including consideration of the new multiple calendars if you have an Exchange account, but with fewer properties available.
tell application "Microsoft Entourage"
set newEvent to make new event with properties {subject:¬
"New Event", start time:¬
date "1/8/07 10 am", end time:¬
date "1/8/07 11 am", remind time:15, location:¬
"Macworld SF", content:"Some notes here." category:¬
{category "Recreation"}}
end tell
See how you can enter the format for short dates on your computer (mine is US) for the start time and end time properties, and Script Editor compiles them to date objects:
tell application "Microsoft Entourage"
set newEvent to make new event with properties {subject:¬
"New Event", start time:¬
date "Monday, January 8, 2007 10:00:00 AM", end time:¬
date "Monday, January 8, 2007 11:00:00 AM", remind time:15, location:¬
"Macworld SF", content:"Some notes here.", category:¬
{category "Recreation"}}
end tell
There are a number of properties in the dictionary available just for Exchange events (not used above), and one property (to recipients) used for making invitations. Be aware that if you include to recipients, the invitation gets sent off as an email message the instant the event is made!
If you set all day event to true, the start time needs to be to midnight , and the end time to midnight of the next day (or several days later if making a multi-day event: always the midnight just after the last day of the event). Entourage should put it right if you get it wrong, but maybe not on quite the day you expect, so it's better to get it right.
To make a recurring event (recurring:true), you'd need to get an appropriate recurrence string off an event of the same recurrence pattern that you've made in the UI. It's far too complicated to learn all the rules (there is an RFC somewhere that details them: it's called an "iCal recurrence".) It‘s probably best to avoid recurrence unless you can just take one from an existing event and set that.
Opening an event (or task or note) is just the same as opening anything else in the Entourage database. Just identify the event and open it. Read the Open Existing Contact section earlier in this chapter. The main difference is that you will often – usually – have more than one event with the same name, so getting it by name only (event "Meeting") is not good enough: it will only get the first one created with that name.
You need a whose clause that filters on both the name and a time "slot". It's usually not a good idea to insist on an exact time, just in case you've got it not quite right: better would be to specify a whole day or week:
tell application "Microsoft Entourage"
set theEvent to first event whose subject is "My Event" and ¬
start time ³ date "Monday, January 8, 2007 12:00:00 AM" and ¬
start time < date "Tuesday, January 9, 2007 12:00:00 AM"
< Previous Page Next Page>
- SPREAD THE WORD:
- Slashdot
- Digg
- Del.icio.us
- Newsvine