3-- !!! Note that this script is not compiled by iCal.xcodeproj, which uses a compiled version instead
4-- !!! so changes to this file will not be reflected in iCal behavior unless manually recompiled.
5-- (Not compiled because of <rdar://problem/3675416> osacompile fails in a chrooted environment)
7-- Simple script derived from 'http://daringfireball.net/2003/02/save_and_restore_safari_urls"
8-- This is used to save the message body to a file
9on save_file(filename, contents)
11 set open_file to open for access POSIX file filename with write permission
12 -- erase current contents of file:
13 set eof of open_file to 0
14 write contents to open_file starting at eof
15 close access open_file
18 close access file filename
23-- We are ignoring the messageText at the moment
24on show_mail_sbrs(subjectLine, messageText, myrecipients)
25 tell application "iTerm"
26 set myterm to (make new terminal)
28 set mysession to (make new session at the end of sessions)
30 set mycommand to "/sw/bin/mutt"
31 set mycommand to mycommand & " -s \"" & subjectLine & "\""
32 set mycommand to mycommand & " -- "
33 repeat with i from 1 to (count of myrecipients)
34 set mycommand to mycommand & " " & (item i of myrecipients)
36 exec command mycommand
44on show_mail_sbr(subjectLine, messageText, myrecipient, myrecipientname)
45 tell application "iTerm"
46 set myterm to (make new terminal)
48 set mysession to (make new session at the end of sessions)
50 set mycommand to "/sw/bin/mutt"
51 set mycommand to mycommand & " -s \"" & subjectLine & "\""
52 set mycommand to mycommand & " -- " & myrecipient
53 exec command mycommand
61on send_mail_sb(subjectLine, messageText)
62 tell application "iTerm"
63 set myterm to (make new terminal)
65 set mysession to (make new session at the end of sessions)
67 set mycommand to "/sw/bin/mutt"
68 set mycommand to mycommand & " -s \"" & subjectLine & "\""
69 exec command mycommand
77on send_mail_sbr(subjectLine, messageText, myrecipient, myrecipientname)
78 show_mail_sbr(subjectLine, messageText, myrecipient, myrecipientname)
81on send_mail_sbrp(subjectLine, messageText, myrecipient, myrecipientname, invitationPath)
82 set mytempdir to do shell script "/usr/bin/mktemp -d -t iCalMutt"
83 set mydestfilename to do shell script "basename \"" & invitationPath & "\""
84 set mydestfilename to mytempdir & "/" & mydestfilename
86 set myBodyFile to mytempdir & "/body.eml"
88 do shell script "cp \"" & invitationPath & "\" \"" & mydestfilename & "\""
90 save_file(myBodyFile, messageText)
92 tell application "iTerm"
93 set myterm to (make new terminal)
95 set mysession to (make new session at the end of sessions)
97 set mycommand to "/sw/bin/mutt"
98 set mycommand to mycommand & " -a \"" & mydestfilename & "\""
99 set mycommand to mycommand & " -s \"" & subjectLine & "\""
100 set mycommand to mycommand & " -i \"" & myBodyFile & "\""
101 set mycommand to mycommand & " -- " & myrecipient
102 exec command mycommand
110on send_mail_sbp(subjectLine, messageText, invitationPath)
111 set mytempdir to do shell script "/usr/bin/mktemp -d -t iCalMutt"
112 set mydestfilename to do shell script "/usr/bin/basename \"" & invitationPath & "\""
113 set mydestfilename to mytempdir & "/" & mydestfilename
115 set myBodyFile to mytempdir & "/body.eml"
117 do shell script "cp \"" & invitationPath & "\" \"" & mydestfilename & "\""
119 save_file(myBodyFile, messageText)
121 tell application "iTerm"
122 set myterm to (make new terminal)
124 set mysession to (make new session at the end of sessions)
126 set mycommand to "/sw/bin/mutt"
127 set mycommand to mycommand & " -a \"" & mydestfilename & "\""
128 set mycommand to mycommand & " -s \"" & subjectLine & "\""
129 set mycommand to mycommand & " -i \"" & myBodyFile & "\""
130 set mycommand to mycommand & " -- " & myrecipient
131 exec command mycommand