所以我一直在寻找一种方法来使用AppleScript按顺序在Mail.app中执行以下操作:
为什么我要做一些看似迟钝的事情?
那么为什么不直接要求直接格式化传出消息的Applescript?
仍在学习使用Applescript的绳索,所以如果有人能够制作出满足要求的AppleScript,那将非常感激。
当我点击“发送消息”(通过可爱的键盘大师)时,我的目的是触发Applescript。
这是我可以提出的骨架AppleScript代码:
set theFont to "Lucida Sans, Lucida Sans Unicode, Lucida Grande, Verdana, Arial"
set theSize to 12
tell application "Mail"
-- 1. intercept an outgoing message
set outMsg to front outgoing message
-- 2. make and exact duplicate of this outgoing message
-- need a little help with extracting...
set fmtMsg to make new outgoing message with properties
{ sender:,
subject:”Convert”,
content:”Please convert and send”
message signature:,
to recipient:,
cc recipient:,
bcc recipient:
}
tell fmtMsg
-- 3. format the text/content etc of this newly made message
set font of content to theFont
set size of content to (theSize)
-- set visible to true
-- 4. send this newly formatted message
send
-- 5. disregard the original one.
-- help?
end tell
end tell
干杯。
答案 0 :(得分:1)
我没有那么多与Mail合作,但我已经编写了一个应该完成这项工作的脚本......
set the mail_recipient to the text returned of (display dialog "To:" default answer "")
set the mail_subject to the text returned of (display dialog "Subject:" default answer "")
set the mail_content to the text returned of (display dialog "Enter your message here (for a new line type \"\\n\"):" default answer "")
set prevTIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to "\\" & "n"
set this_text to every text item of the mail_content
set AppleScript's text item delimiters to return
set the mail_content to this_text as string
tell application "Mail"
tell (make new outgoing message with properties {visible:true, subject:mail_subject, content:mail_content})
make new to recipient at the end of to recipients with properties {address:mail_recipient}
send
end tell
end tell
我没有在脚本中添加错误检查(检查收件人的有效地址)。
正如您所说,您无法更改收件人的字体;这可能被视为骚扰。
如果此脚本不能令人满意,请告诉我,我会为您更改。 :)
更新:我刚刚阅读了AppleScript与Mail的使用,并且意识到Mail对AppleScript有很大的限制。我认为你最好的选择是使用GUI Scripting
。这个脚本有点hacky,但它应该可以工作。
tell application "System Events" to tell process "Mail" to set the mail_subject to (get the value of the first text box)
tell application "Mail" to set this_message to the content of the first message of mailbox "Sent" whose subject is the mail_subject
更新2:
tell application "System Events"
tell process "Mail"
set the mail_recipient to (get the value of the first text field)
set the mail_subject to (get the value of the fourth text field)
set the mail_content to (get the value of the last text field)
my create_new_message(mail_recipient, mail_subject, mail_content)
end tell
end tell
on create_new_message(recipient, subject, content)
tell application "Mail"
quit saving no
activate
tell (make new outgoing message with properties {subject:|subject|, content:|content|)
make new recipient at the end of to recipients with properties {address:|recipient|}
send
end tell
end tell
end create_new_message