Outlook 2011 supports option-click-drag to copy a pure appointment calendar item (one with no attendees), but has no facility to copy or duplicate a meeting item (one with attendees). I figure there must be a way to do this in AppleScript.
Asked
Active
Viewed 2,110 times
1 Answers
0
The code first makes sure that there is a calendar event selected in Outlook. It then invokes a subroutine to copy it.
I was unable to simply set the properties list of the new event to that of the original, as AppleScript complained that it could not coerce a string into the class of any of the Outlook types. Very frustrating, and likely something that someone who is better at AppleScript could easily solve. But, I discovered through trial and error that setting a property to a non-null string does work, so I set a set of variables to the essential properties of an event, and if they are not null, set the property of the new event to it.
(*
--------------------------------------------
Duplicate Calendar Event 1.0
-------------------------------------------
based on "Set Custom Reminder 1.0" by William Smith <bill@officeformachelp.com>
It is only compatible with Outlook for Mac 2011.
--------------------------------------------
This script duplicates a calendar event that has attendees.
(Outlook supports option-click-drag to copy a pure appointment event, one with no
attendees, but does not support any means of copying or duplicating a meeting
event with attendees)
*)
tell application "Microsoft Outlook"
-- Is the event selected in the Calendar view of the Main Window?
if class of front window is main window and view of front window is calendar view then
-- If so...
set orig_event to the selection
if class of orig_event is calendar event then
my copy_event(orig_event)
end if
-- Is this a new unsaved appointment or meeting?
else if class of front window is window and object of front window is missing value then
-- If so...
display dialog "Unsaved events cannot be copied. Save your event and run this script again." with title "Alert!" with icon 2 buttons {"OK"} default button {"OK"}
else if class of front window is window and (class of object of front window) is calendar event then
-- If so...
set orig_event to object of front window
my copy_event(orig_event)
else
-- No calendar event appears to be selected or open. Therefore...
display dialog "Select an event from your calendar first or open its window." with title "Alert!" with icon 2 buttons {"OK"} default button {"OK"}
end if
end tell
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
on copy_event(orig_event)
tell application "Microsoft Outlook"
set the_properties to properties of orig_event
set Loc to ""
--set Rec to "" -- don't know how to handle recurrence since it itself is a list
set RecID to ""
set Subj to ""
set StarT to ""
set StarD to ""
set EndT to ""
set EndD to ""
set Cont to ""
set Rem to ""
if ((location of the_properties) as string) does not contain "missing value" then set Loc to (location of the_properties)
if ((recurrence id of the_properties) as string) does not contain "missing value" then set RecID to (recurrence id of the_properties)
if ((subject of the_properties) as string) does not contain "missing value" then set Subj to ((subject of the_properties) as string)
if ((start time of the_properties) as string) does not contain "missing value" then set StarT to (start time of the_properties)
if ((end time of the_properties) as string) does not contain "missing value" then set EndT to (end time of the_properties)
if ((content of the_properties) as string) does not contain "missing value" then set Cont to (content of the_properties)
if ((reminder time of the_properties) as string) does not contain "missing value" then set Rem to (reminder time of the_properties)
set Cat to (category of the_properties)
make new calendar event with properties ¬
{location:Loc, subject:Subj, content:Cont, start time:StarT, end time:EndT, reminder time:Rem, category:Cat}
set theID to the result
--display dialog "created new event"
set the_attendees to every optional attendee of orig_event
set attendee_count to count of the_attendees
--display dialog "event has " & attendee_count & " optional attendees"
repeat with an_attendee in the_attendees
set attendee_properties to properties of an_attendee
set att_name to ((name of (email address of attendee_properties)) as string)
set att_email to ((address of (email address of attendee_properties)) as string)
make new optional attendee at theID with properties {email address:{name:att_name, address:att_email}}
end repeat
set the_attendees to every required attendee of orig_event
set attendee_count to count of the_attendees
--display dialog "event has " & attendee_count & " required attendees"
repeat with an_attendee in the_attendees
set attendee_properties to properties of an_attendee
set att_name to ((name of (email address of attendee_properties)) as string)
set att_email to ((address of (email address of attendee_properties)) as string)
make new required attendee at theID with properties {email address:{name:att_name, address:att_email}}
end repeat
set the_attendees to every resource attendee of orig_event
set attendee_count to count of the_attendees
--display dialog "event has " & attendee_count & " resource attendees"
repeat with an_attendee in the_attendees
set attendee_properties to properties of an_attendee
set att_name to ((name of (email address of attendee_properties)) as string)
set att_email to ((address of (email address of attendee_properties)) as string)
make new resource attendee at theID with properties {email address:{name:att_name, address:att_email}}
end repeat
--send meeting theID -- don't send the meeting, give owner a chance to edit first
open theID
end tell
return
end copy_event
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
on lowercase(aString)
set NewString to do shell script "echo " & aString & " | tr '[A-Z]' '[a-z]'"
return NewString
end lowercase

jetset
- 388
- 4
- 14