0

Outlook 2011 支持选项单击拖动以复制纯约会日历项目(一个没有与会者),但无法复制或复制会议项目(一个有与会者)。我认为AppleScript中必须有一种方法可以做到这一点。

4

1 回答 1

0

该代码首先确保在 Outlook 中选择了一个日历事件。然后它调用一个子例程来复制它。

我无法简单地将新事件的属性列表设置为原始事件的属性列表,因为 AppleScript 抱怨它无法将字符串强制转换为任何 Outlook 类型的类。非常令人沮丧,并且可能是更擅长 AppleScript 的人可以轻松解决的问题。但是,我通过反复试验发现将属性设置为非空字符串确实有效,因此我将一组变量设置为事件的基本属性,如果它们不为空,则设置新事件的属性给它。

(*

--------------------------------------------
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
于 2015-01-29T03:31:35.683 回答