Re: Setting Calendar Category in Apple Script
Re: Setting Calendar Category in Apple Script
- Subject: Re: Setting Calendar Category in Apple Script
- From: Paul Berkowitz <email@hidden>
- Date: Mon, 21 Jan 2013 15:45:18 -0800
- Thread-topic: Setting Calendar Category in Apple Script
Title: Re: Setting Calendar Category in Apple Script
On 1/12/13 8:57 AM, "Peter R Hawkes" <email@hidden> wrote:
Outlook 2011 Query:
As part of a longer script I am trying to create calendar events and add a category to that event;
set newEvent to make new calendar event with properties {all day flag:true, subject:myEvent, location:myLocation, start time:startTime, end time:endTime}
creates the event but what I can not work out is then how to set the category to that new event?
I don't have Outlook, but assuming it's similar to Entourage 2011, you have to add the category as the first, or only, item of a list. I believe that in Outlook, this was made clearer by naming the relevant property 'categories' (plural), which is a list. (In Entourage is was also a list, but named 'category', which was confusing.) You should be able to see that in the dictionary, where the 'type' of 'categories' property of 'calendar event' should be 'list of category'.
You could previously have set a variable 'myCategory' to an existing category, e.g.
set myCategory to category "Work"
So, assuming your category of choice exists and has a variable 'myCategory' set to it, you ought to be able to do it like this:
set newEvent to make new calendar event with properties {all day flag:true, subject:myEvent, location:myLocation, start time:startTime, end time:endTime, categories:{myCategory})}
Just in case there's some sort of bug that prevents you from setting the category at inception in Outlook, you'd add it to your newEvent after creating it this way:
set newEvent to make new calendar event with properties {all day flag:true, subject:myEvent, location:myLocation, start time:startTime, end time:endTime}
set category of newEvent to {myCategory}
Note: You can also create a new category with its own name and color, if you wish:
set myCategory to make new category with properties {name: "Fanciful", color: {12345, 23456,11111}}
--
Paul Berkowitz
_______________________________________________
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