Script for Entourage event, note, task to iCal?

  • Thread starter Steven Paul Day
  • Start date
S

Steven Paul Day

Am I correct in assuming that there is no script for creating events, notes,
or tasks in Entourage for iCal? Life would be great if that were the case.
Otherwise, Paul's script for syncing Ent-iCal must be the best option.

Thanks in advance.

Steven
 
P

Paul Berkowitz

Am I correct in assuming that there is no script for creating events, notes,
or tasks in Entourage for iCal? Life would be great if that were the case.
Otherwise, Paul's script for syncing Ent-iCal must be the best option.

iCal doesn't have notes, so that part can't exist, script or no script.

And unfortunately, the notes of todos are not scriptable in iCal (although
you can write todo notes manually there). Please write Apple asking for them
to be made scriptable.

Otherwise I'm not quite sure what you mean by "script for creating events
and tasks in iCal FROM Entourage". Why would you want to do it from
Entourage when Entourage has its own events and tasks? Just click on iCal in
the Dock and make your event or todo there, if that's what you want. If you
want them to exist in _both_ apps, then you'd need something like my script.
If you run it just after making a new event or task in Entourage it will
only take a few seconds to run and sync the new items over.
 
P

Paul Berkowitz

Otherwise I'm not quite sure what you mean by "script for creating events
and tasks in iCal FROM Entourage". Why would you want to do it from
Entourage when Entourage has its own events and tasks? Just click on iCal
in the Dock and make your event or todo there, if that's what you want. If
you want them to exist in _both_ apps, then you'd need something like my
script. If you run it just after making a new event or task in Entourage
it will only take a few seconds to run and sync the new items over.

And you can run the Sync script from the "Run Sync-iCal Script" trigger
script in the Entourage script menu, if you wish, making it quite easy to
access. You could even give it a keyboard shortcut if you wished. (See
"About the script menu" in Entourage Help.)
 
S

Steven Paul Day

Guess my posting was not very clear.

Yes, iCal is rather primitive now that I've looked at some of its
limitations. What I was thinking of was a script that would allow you to
create an event from an Entourage email in iCal. Such a script does exist
for Mail, I believe.

Why would I want to do that? Well, iCal is much nicer to look at than
Entourage's calendar for one. iCal also works seamlessly with Calendarclock;
Entourage does not. Rather than syncing the two calendars, it seems much
simpler to just add events to iCal directly. Think I'll just run your
syncing script if there's nothing else.

Thanks.
 
B

Brett Zamir

It looks like it should be possible since iCal's dictionary shows quite a
bit under the iCal suite (under class "event"). You'd have to parse the
email then and find the dates or whatever you wanted to extract in creating
your event.

Brett
 
B

Brett Zamir

Sure. What data did you want to extract from the email to go into the event?
(exactly what fields)

Brett
 
S

Steven Day

iCal doesn't have notes, so that part can't exist, script or no script.

Right. I was confused because there is a note field in the Info window.
And unfortunately, the notes of todos are not scriptable in iCal (although
you can write todo notes manually there). Please write Apple asking for them
to be made scriptable.

There is a Mail2iCalTodo script, however. But "to dos" are still not
scriptable?
 
S

Steven Day

iCal doesn't have notes, so that part can't exist, script or no script.

Right. I was confused because there is a note field in the Info window.
And unfortunately, the notes of todos are not scriptable in iCal (although
you can write todo notes manually there). Please write Apple asking for them
to be made scriptable.

There is a Mail2iCalTodo script, however. But "to dos" are still not
scriptable?

Thanks for your help Paul.
 
S

Steven Day

Thanks Brett. Basically, I would like to have the message body go into an
event, which could then be edited. That's the way it works for both
Entourage>Calendar Event, and Mail2iCal. Then from within Calendar or iCal,
the event content can be further edited.

Here's the script from MS for Entourage, if that helps. Mail2iCal is below:

(*
Create Event from Message

Copyright (c) Microsoft Corporation. All rights reserved.
*)

tell application "Microsoft Entourage"

-- get the currently selected message or messages
set selectedMessages to current messages

-- if there are no messages selected, warn the user and then quit
if selectedMessages is {} then
display dialog "Please select a message first and then run this
script." with icon 1
return
end if

repeat with theMessage in selectedMessages

-- get the information from the message, and store it in variables
set theName to subject of theMessage
set theCategory to category of theMessage
set theContent to content of theMessage

-- create a new note with the information from the message
set newEvent to make new event with properties {subject:theName,
category:theCategory, content:theContent}

-- create a link between the message and the new note
link theMessage to newEvent

-- if there was only one message selected, then open that new note
if (count of selectedMessages) = 1 then open newEvent
end repeat
end tell

_____________________________________________________________

property pCalName : ""
property pDontAsk : false

on perform_mail_action(info)
set mailCal to my checkForDefault()
set allMessages to |SelectedMessages| of info
my generateItems(allMessages, mailCal)
end perform_mail_action

on run
tell application "Mail"
if (count of selected messages of message viewer 1) is not 0 then
set mailCal to my checkForDefault()
set allMessages to selected messages of message viewer 1
my generateItems(allMessages, mailCal)
else
display dialog "Please select some messages to export" buttons
{"OK", "Reset"} default button 1
copy result as list to {theButton}
if theButton is "Reset" then
set pDontAsk to false
end if
end if
end tell
end run

on getIndex(theItem, theList)
repeat with i from 1 to count of theList
if theItem is item i of theList then
return i
end if
end repeat
return -1
end getIndex

on checkForDefault()
tell application "iCal"
set allCals to title of calendars
if pDontAsk is false then
set theCal to choose from list allCals with prompt "Export to
which calendar" default items {pCalName} cancel button name "New" with empty
selection allowed without multiple selections allowed
if theCal is false or (count of theCal) is 0 then
display dialog "Name your calendar" default answer "Email"
buttons {"Cancel", "Use", "Keep"} default button 2
copy the result as list to {theName, theButton}
if theButton is not "Cancel" then
set pCalName to theName
if theButton is "Keep" then
set pDontAsk to true
end if
else
return
end if
set mailCal to make new calendar at the end of calendars
tell mailCal
set title to pCalName
end tell
else
display dialog "Keep this calendar as default?" buttons
{"Keep", "Don't Keep"} default button 2
copy the result as list to {theButton}
if theButton is "Keep" then
set pDontAsk to true
end if
set pCalName to item 1 of theCal
set mailCal to calendar (my getIndex(pCalName, allCals))
end if
else
set calIndex to (my getIndex(pCalName, allCals))
if calIndex is -1 then
display dialog "Your default calendar is missing, retry and
choose new calendar." buttons {"OK"} default button 1 with icon stop
set pDontAsk to false
return
else
set mailCal to calendar calIndex
end if
end if
end tell
return mailCal
end checkForDefault

on generateItems(allMessages, mailCal)
tell application "Mail"
repeat with curMessage in allMessages
set theSender to sender of curMessage
set theSubject to subject of curMessage
set theBody to content of curMessage
set theDate to date sent of curMessage
tell application "iCal"
set newEvent to (make new event at the end of events in
mailCal)
tell newEvent
set start date to theDate
set end date to ((theDate + minutes) as date)
set summary to (theSender & ", " & theSubject)
set description to theBody
end tell
end tell
end repeat
end tell
end generateItems
 
P

Paul Berkowitz

Right. I was confused because there is a note field in the Info window.


There is a Mail2iCalTodo script, however. But "to dos" are still not
scriptable?

Todos are definitely scriptable. Todo _notes_ are not scriptable. One of
about 100 bugs in iCal scripting... That one can't be worked around. Event
notes are scriptable.
Thanks for your help Paul.

Sure.


--
Paul Berkowitz
MVP MacOffice
Entourage FAQ Page: <http://www.entourage.mvps.org/faq/index.html>
AppleScripts for Entourage: <http://macscripter.net/scriptbuilders/>

Please "Reply To Newsgroup" to reply to this message. Emails will be
ignored.

PLEASE always state which version of Microsoft Office you are using -
**2004**, X or 2001. It's often impossible to answer your questions
otherwise.
 
B

Brett Zamir

Do you mean have the message body go into the notes of an event? If so,
that should be possible, since the iCal "event" class has the property of a
"description" which is the same as the notes of an event (though as Paul
already mentioned, you can't have anything go into a todo's notes). You
should also be able to get an Entourage note or task's notes into an iCal
event.

Brett
 
P

Paul Berkowitz

Although you can extract all the data from Entourage, there are lots of bugs
to beware of in iCal, and a few in Entourage.

In particular, all day event start and end times are completely screwed up
in iCal. Making an all-day event puts the start time, initially, at your
local time zone's equivalent of whenever midnight would be in Greenwich Mean
Time! Compounding that error is another in that iCal tries to fix that
non-midnight time (e.g. 5 pm the preceding day if you're in PDT) by pushing
it back to midnight of this (incorrect) day. Then a THIRD error comes into
play in that it translates that time too from GMT. So you end up with an
event that looks in iCal; as if it starts two days too early. Only it's not
two _full_ days, so things get screwier - it doesn't look like an all-day
event at all but like a regular event. The wend time does not always behave
the same way as the start time: it's usually midnight of the correct day.
Things are made worse by having to know whether the date is in standard or
in daylight savings time to know how far out from GMT it is - it may be
different than the current day when the script runs.

Had enough? ;-) That's the worst one, but there's lots more like this. I
really can't recommend wading into these waters unless you're an expert and
are prepared to to find workarounds. iCal and Entourage don't do recurring
events exactly the same way, and there's another bug with the recurrence
string in iCal. Alarms are done totally differently from Entourage reminders
(which have their own bugs). The script you quote gets Entourage categories,
but iCal doesn't have categories - you have to decide whether you want a
separate calendar for each Entourage category, and the structure is the
other way around. (The events belong to calendars in iCal, whereas the
categories belong to events in Entourage.)

This could take you a little while... It took me several months.

--
Paul Berkowitz
MVP MacOffice
Entourage FAQ Page: <http://www.entourage.mvps.org/faq/index.html>
AppleScripts for Entourage: <http://macscripter.net/scriptbuilders/>

Please "Reply To Newsgroup" to reply to this message. Emails will be
ignored.

PLEASE always state which version of Microsoft Office you are using -
**2004**, X or 2001. It's often impossible to answer your questions
otherwise.
 
S

Steven Day

Wow. What is Apple doing?

If it took you several months, I would need several lifetimes.

I did notice upon importing into iCal that re-occurring Entourage events
that were interrupted from their normally scheduled times (on Labor Day and
Thanksgiving, for example) would nevertheless show up in the former, even
though they had been deleted in Entourage. So I suspected some trouble
between the applications.

Your script then must handle these problems as well as one could expect,
given all the issues.

Thanks again.

Steven
 
Top