|
-- Outlook 2003 is still not RFC 2445 compliant, so this script strips out the VTIMEZONE and TZID portions of the the .ics file that confuse Outlook (causing, for example, the "Gregorian"/"Lunar" import error in Outlook 2003) |
|
-- I've restricted the script to recipients in a specific domain because I don't want to affect notifications to potential non-Outlook recipients. Feel free to change or remove that logic to fit your particular needs. |
|
|
|
-- Note that the invitation times will only be accurate for Outlook users in the same time zone as the sender. This is because Outlook doesn't know how to handle time zones (it expects GMT (i.e. Zulu) times). Ideally, this script would translate all times to GMT, but that's more than I need right now, so the script just strips out all time zone information, and Outlook assumes the imported times refer to local time. |
|
|
|
-- In Terminal, open /Applications/iCal.app/Contents/Resources/Mail.scpt |
|
-- ## Remember to back up your original Mail.scpt file! |
|
-- Replace the send_mail_sbrp function with the following. Keep all other functions as they are. |
|
|
|
|
|
-- Mail.scpt hack for Outlook compatibility - Bryan's version |
|
on send_mail_sbr(subjectLine, messageText, myrecipient) |
|
tell application "Mail" |
|
set mymail to (make new outgoing message at the beginning of outgoing messages with properties {subject:subjectLine, content:messageText}) |
|
tell mymail to make new to recipient at beginning of to recipients with properties {address:myrecipient} |
|
send mymail |
|
end tell |
|
end send_mail_sbr |
|
|
|
-- Mail.scpt hack for Outlook compatibility - Bryan's version |
|
on send_mail_sbrp(subjectLine, messageText, myrecipient, myrecipientname, invitationPath) |
|
set pfile to POSIX file invitationPath |
|
set myfile to pfile as alias |
|
|
|
try |
|
-- if appointment going to Thy, then parse for outlook |
|
-- define a carriage return |
|
set cr to (ASCII character 13) & (ASCII character 10) |
|
|
|
-- open and read the ical event file to insert into an e-mail |
|
set myEventFileHandle to ¬ |
|
open for access myfile without write permission |
|
set myEventFileContent to read myEventFileHandle |
|
close myEventFileHandle |
|
|
|
-- remove the timezone info from the calendar event |
|
-- to make compatable with outlook |
|
set toss to false |
|
set newEventFileContent to "" |
|
set last_line to false |
|
repeat with theLine in paragraphs of myEventFileContent |
|
if theLine contains "BEGIN:VTIMEZONE" then |
|
set toss to true |
|
else if theLine contains "END:VTIMEZONE" then |
|
set last_line to true |
|
set toss to false |
|
end if |
|
if toss is false then |
|
if last_line is true then |
|
set last_line to false |
|
else |
|
if theLine contains ";TZID=US/Pacific" then |
|
set theLine to searchReplace(theLine, ";TZID=US/Pacific", "") |
|
end if |
|
set newEventFileContent to newEventFileContent & theLine & cr |
|
end if |
|
end if |
|
end repeat |
|
|
|
-- create a random event file name |
|
set aliasTempMail to "/tmp/" & (random number from 1 to 1000000) & ".ics" |
|
|
|
-- write the new event to a temp file |
|
set myEventFileHandle to ¬ |
|
open for access (POSIX file aliasTempMail as string) with write permission |
|
write newEventFileContent starting at 1 to myEventFileHandle as «class utf8» |
|
close myEventFileHandle |
|
|
|
set pfile to POSIX file aliasTempMail |
|
set myfile to pfile as alias |
|
-- display dialog "ready for Outlook" |
|
on error errMsg |
|
display dialog errMsg |
|
end try |
|
|
|
try |
|
tell application "Mail" |
|
set mymail to (make new outgoing message at the beginning of outgoing messages with properties {subject:subjectLine, content:messageText}) |
|
tell mymail to make new to recipient at beginning of to recipients with properties {address:myrecipient} |
|
tell mymail |
|
tell content |
|
make new attachment with properties {file name:myfile} at after the last word of the the last paragraph |
|
end tell |
|
end tell |
|
send mymail |
|
end tell |
|
on error errMsg |
|
display dialog errMsg |
|
end try |
|
end send_mail_sbrp |
|
|
|
to searchReplace(thisText, searchTerm, replacement) |
|
set AppleScript's text item delimiters to searchTerm |
|
set thisText to thisText's text items |
|
set AppleScript's text item delimiters to replacement |
|
set thisText to "" & thisText |
|
set AppleScript's text item delimiters to {""} |
|
return thisText |
|
end searchReplace |