changelog shortlog tags changeset files revisions annotate raw

osx/Mail.applescript

changeset 20: b6b0e9bc226d
parent:caa436899d24
author: Greg Darke <greg+laptop@tsukasa.net.au>
date: Thu Apr 16 00:45:45 2009 +1000 (15 months ago)
permissions: -rw-r--r--
description: Ignore some stuff
1-- Mail.applescript
2-- iCal
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)
6
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)
10 try
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
16 on error
17 try
18 close access file filename
19 end try
20 end try
21end save_file
22
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)
27 tell myterm
28 set mysession to (make new session at the end of sessions)
29 tell mysession
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)
35 end repeat
36 exec command mycommand
37 end tell
38 end tell
39
40 activate
41 end tell
42end show_mail_sbrs
43
44on show_mail_sbr(subjectLine, messageText, myrecipient, myrecipientname)
45 tell application "iTerm"
46 set myterm to (make new terminal)
47 tell myterm
48 set mysession to (make new session at the end of sessions)
49 tell mysession
50 set mycommand to "/sw/bin/mutt"
51 set mycommand to mycommand & " -s \"" & subjectLine & "\""
52 set mycommand to mycommand & " -- " & myrecipient
53 exec command mycommand
54 end tell
55 end tell
56
57 activate
58 end tell
59end show_mail_sbr
60
61on send_mail_sb(subjectLine, messageText)
62 tell application "iTerm"
63 set myterm to (make new terminal)
64 tell myterm
65 set mysession to (make new session at the end of sessions)
66 tell mysession
67 set mycommand to "/sw/bin/mutt"
68 set mycommand to mycommand & " -s \"" & subjectLine & "\""
69 exec command mycommand
70 end tell
71 end tell
72
73 activate
74 end tell
75end send_mail_sb
76
77on send_mail_sbr(subjectLine, messageText, myrecipient, myrecipientname)
78 show_mail_sbr(subjectLine, messageText, myrecipient, myrecipientname)
79end send_mail_sbr
80
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
85
86 set myBodyFile to mytempdir & "/body.eml"
87
88 do shell script "cp \"" & invitationPath & "\" \"" & mydestfilename & "\""
89
90 save_file(myBodyFile, messageText)
91
92 tell application "iTerm"
93 set myterm to (make new terminal)
94 tell myterm
95 set mysession to (make new session at the end of sessions)
96 tell mysession
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
103 end tell
104 end tell
105
106 activate
107 end tell
108end send_mail_sbrp
109
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
114
115 set myBodyFile to mytempdir & "/body.eml"
116
117 do shell script "cp \"" & invitationPath & "\" \"" & mydestfilename & "\""
118
119 save_file(myBodyFile, messageText)
120
121 tell application "iTerm"
122 set myterm to (make new terminal)
123 tell myterm
124 set mysession to (make new session at the end of sessions)
125 tell mysession
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
132 end tell
133 end tell
134
135 activate
136 end tell
137end send_mail_sbp
138