Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Some additions...' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Some additions...
Authored by: svinki on Jan 28, '03 07:10:42PM

A collegue and I tackled this same problem last week...here are some additional tips:

1. In addition to scanning "Content-Class" for "calendarmessage", you'll also need to scan that header for "appointment". This covers different ways people can schedule meetings in Outlook.

2. Try saving the .ics file to Temporary Items, and then set the Applescript to tell Finder to open said file. This will feed the file to iCal, which will present a meeting invitation dialog. From there, you can accept (or decline) the meeting and choose which calendar will receive the event. With that change in place, you should also be able to get rid of the intervening Applescript dialog. The .ics file will eventually be deleted by the system.

3. Additional caveats: This will not "Update" meetings...you'll have to do that manually by deleting the previous version of the meeting from iCal and then importing the new, updated version.

I wish it were more robust, but it's a good stopgap until Apple gets this working the Right Way. =)



[ Reply to This | # ]
Some additions...
Authored by: svinki on Jan 28, '03 08:00:59PM

That should be "colleague". =b



[ Reply to This | # ]
Some additions...
Authored by: anandman on Mar 04, '03 10:38:15PM
Following your suggestions, I've come up with this script. For some reason, I can't overwrite the the temporary file so I had to insert the 'rm' command before trying to open it. This works well for me though.
property beginTag : "BEGIN:VCALENDAR"
property endTag : "END:VCALENDAR"

on perform_mail_action(info)
  tell application "Mail"
    set selectedMessages to |SelectedMessages| of info
    set theRule to |Rule| of info
    repeat with eachMessage in selectedMessages
      set theSubject to subject of eachMessage
      set theRuleName to name of theRule
      set theContent to content of eachMessage

      if (theContent contains beginTag) ¬
        and (theContent contains endTag) then
        -- extract vcalendar from message
        set theCal to ¬
          text from character (offset of beginTag in theContent) ¬
            to character ((offset of endTag in theContent) ¬
            + (length of endTag)) of theContent

        -- save vcalendar to file
        set theFileName to ¬
          (path to temporary items folder type string) ¬
            & "Mail2iCal.ics"
        set theFileNamePOSIX to POSIX path of theFileName
        try
          set theCommand to "rm -f '" & theFileNamePOSIX & "'"
          do shell script theCommand
        on error
          display dialog "ERROR: Can't delete file " & theFileNamePOSIX
        end try
        try
          set theFile to (open for access theFileName with write permission)
        on error
          display dialog "ERROR: Can't open file " & theFileName
          try
            close access theFileName -- use the file name rather than the ref
          end try
        end try
        try
          set eof of theFile to 0
          write theCal as string to theFile starting at eof
          close access theFile
        on error
          display dialog "ERROR: Can't write or close file " & theFileName
          try
            close access theFile
          end try
        end try

        -- open vCalendar file with iCal
        set theCommand to "open -a '/Applications/iCal.app' '" & theFileNamePOSIX & "'"
        do shell script theCommand
      end if
    end repeat
  end tell
end perform_mail_action
-anand

[ Reply to This | # ]
Some additions...
Authored by: anandman on Mar 04, '03 10:44:41PM
Oops. I forgot to change one thing. For some reason, Script Editor's check syntax changes and "as" to "type" and lets me compile it and save it the first time but when you try to check syntax or save it again it fails. Anyone know why?

Anyway, just change the following line:

  (path to temporary items folder type string)
to
  (path to temporary items folder as string)

-anand

[ Reply to This | # ]