/
ComposeMail.applescript
52 lines (47 loc) · 1.68 KB
/
ComposeMail.applescript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
(*
name: Compose mail
apps: Mail
description: Quickly compose an email in Mail.app
parameters:
SUBJ: Subject line
SENDR: Sending account to use
RECEIPIENTS: List of recipient mails
CC: List of cc mails
BCC: List of bcc mails
TESNIP: Abbreviation of a TextExpander snippet to use as content
compile: false
*)
-- Subject line
property SUBJ : ""
-- Sending account to use. Needs to be in the format "Name <Mail>" and
-- exactly match the name and mail in the account settings. Leave blank to
-- use the default account.
property SENDR : ""
-- Recipients (normal, cc and bcc) for the mail. Just enter mail adresses.
property RECEIPIENTS : {""}
property CC : {}
property BCC : {}
-- an optional TextExpander snippet to set as the content
property TESNIP : ""
tell application "Mail"
set SNIP to ""
if TESNIP is not "" then
tell application "TextExpander"
set allSNIPs to (every snippet in every group whose abbreviation is TESNIP)
repeat with GRP in allSNIPs
if (count of GRP) > 0 then set SNIP to rich text expansion of first item of GRP
end repeat
end tell
end if
set newMail to make new outgoing message with properties {subject:SUBJ, sender:SENDR, content:SNIP, visible:true}
repeat with R in RECEIPIENTS
make new to recipient at end of newMail's to recipients with properties {name:"", address:R}
end repeat
repeat with C in CC
make new cc recipient at end of newMail's cc recipients with properties {name:"", address:C}
end repeat
repeat with B in BCC
make new bcc recipient at end of newMail's bcc recipients with properties {name:"", address:B}
end repeat
activate
end tell