|
|
Some additions...
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
Some additions...
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 |
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.09 seconds |
|