Title: Re: Script idea
On 11/17/00 4:36 AM, "Nicolai Amter" <[EMAIL PROTECTED]> wrote:
> I wonder if this is possible?
>
> Is anybody interested in writing a script that would look in the calendar
> and automatic send all meetings with a specific category to either
> predefined email addresses or people you choose.
>
> /Nicolai
>
Here is the script (already checked out by Nicolai).
This is how to use it:
Open the Address Book and command-click to select any number of contacts and/or groups to whom you want invites to go to. (For example, you could have a group which has all your regular group members concerned, but you could add, for this purpose only, a few other contacts as well. Click the group and the extra contacts. Or just select contacts if you prefer.) Then run the script from the menu. It will offer you a choice of your categories. Select one (or command-click to select more than one.)
The script will then find every calendar event of that category which is in the future or is a recurring event, and will send an invite out to your selected group and/or contacts. You will see what looks like blank windows opening up and closing but they actually have all the information. Then you get a message at the end to say it's all done. Because of two separate flaws in Entourage's scripting, it takes longer than it should (it has to search through all your events, including every holiday over a five-year period!) but it still seems pretty fast to me.
In order not to wipe out invitees who you may have already invited, and their Attendee status, it sends an "Update" under such circumstances, so those already invited get an update (with no new info). There was no other way to do it that wouldn't wipe them out of all the records.
By "demand", the script is set to queue all the invitations in the outbox. To have it send the invitations out immediately as the script is run (Send Now), have Akua Sweets scripting addition in your Scripting Additions folder in System folder. (You can get free it at http://macscripter.net or http://homepage.mac.com/berkowit28/ . Install it and restart computer.) Run the script with the command key down to toggle the Send Now/Send Later behavior setup (only). Then run it normally. Akua Sweets will also put the list of categories into alphabetical order.
I will also be posting the script with a ReadMe at <http://homepage.mac.com/berkowit28/ > and at AppleScript Central <http://www.applescriptcentral.com/>.
------------------------ SEND CATEGORY INVITATIONS E ----------------------
property ifSo : true
try -- with Akua Sweets
if (get input state) contains {modifier keys:"C"} then set ifSo to not ifSo --reset to send now (or send later)
if ifSo = false then
display dialog "Send Category Invitations script is now set to send invitations out immediately (Send Now) as the script is run." buttons {"OK"} default button "OK" with icon 1
else
display dialog "Send Category Invitations script is now set to queue invitations in the out box (Send Later)." buttons {"OK"} default button "OK" with icon 1
end if
return
end try
tell application "Microsoft Entourage"
try -- may be no selection
set theSelection to the selection as list
if class of item 1 of theSelection is not in {group, contact} then error -128 -- enforce error
on error
beep
display dialog "You must select one or more groups or contacts in the Address Book before running this script." buttons {"OK"} default button "OK" with icon 0
return
end try
set theTo to {}
set cNum to (count theSelection)
repeat with i from 1 to cNum
set theContact to item i of theSelection
if class of theContact = contact then
set end of theTo to default email address of theContact
else -- group
set groupMembers to every group entry of theContact
set gNum to count groupMembers
repeat with j from 1 to gNum
set end of theTo to address of content of item j of groupMembers
end repeat
end if
end repeat
set {ods, AppleScript's text item delimiters} to {AppleScript's text item delimiters, {", "}}
set theTo to "" & theTo
set AppleScript's text item delimiters to ods
set theCategories to name of every category
try -- with Akua Sweets
set theCategories to order list theCategories
end try
set catChoice to choose from list theCategories with prompt "Send invites for calendar events of which category? (Command-click to select more than one.)" with multiple selections allowed
if catChoice = false then return
set now to (current date)
set allEvents to every event
set eNum to count allEvents
repeat with k from 1 to eNum
set theEvent to item k of allEvents
set eventCategories to category of theEvent
set ecNum to count eventCategories
repeat with n from 1 to ecNum
set aCategory to item n of eventCategories
if {name of aCategory} is in catChoice then
if recurring of theEvent or start time of theEvent > now then
open theEvent
set oldTo to (to recipients of window 1)
if oldTo � "" then set oldTo to oldTo & ", "
set to recipients of window 1 to (oldTo & theTo)
ignoring application responses -- avoid spell-checker
send window 1 sending later ifSo
end ignoring
end if
end if
end repeat
end repeat
if ifSo then
set w to "in outbox."
else
set w to "sent."
end if
beep
display dialog "All done!" & return & return & "All invitations " & w buttons {"OK"} default button "OK" with icon 1
end tell
-----------------------end script-------------------------------------
--
Paul Berkowitz
- Script idea Nicolai Amter
- Re: Script idea Allen Watson
- Re: Script idea Paul Berkowitz
- Re: Script idea Dan Crevier
- Error Window Paul Berkowitz
- Error Window David
