[英]Adding Line Break to Email Body Content of Mail.app Message Generated in AppleScript
我目前正在使用以下脚本发送带有指定主题,附件和正文消息的电子邮件:
on run argv
set theSubject to (item 1 of argv)
set theAttachmentFile to (item 2 of argv)
set theContent to (item 3 of argv)
tell application "Mail"
set theAddress to {"test@gmail.com"} -- the receiver
set theSignatureName to "Test" -- the signature name
set msg to make new outgoing message with properties {subject:theSubject, content:theContent, visible:true}
tell msg
repeat with i from 1 to count theAddress
make new to recipient at end of every to recipient with properties {address:item i of theAddress}
end repeat
end tell
tell msg to make new attachment with properties {file name:theAttachmentFile as alias}
set message signature of msg to signature theSignatureName
send msg
end tell
end run
我一直在Mac Terminal中使用以下命令执行脚本:
osascript /Users/dwm8/Desktop/email.scpt "Test" "dwm8:test.pdf" "Test Message Here"
但是,我想对我发送的电子邮件的正文消息进行一些小的更改。 而不是发送消息
Test Message Here
我想在邮件正文中说
Test Message Here
我可以在哪里指定换行符的位置。 有谁知道我可以在现有脚本中实现它吗? 谢谢您的帮助!
添加回车符:
osascript /Users/dwm8/Desktop/email.scpt "Test" "dwm8:test.pdf" "Test ^MMessage^M Here"
其中^ M是按ctrl-v然后按ctrl-m时得到的结果。
您可以使用\\n
或& return
插入回车& return
:
"Test\nMessage\nHere"
要么...
"Test" & return & "Message" & return & "Here"
消息的内容始终是第三个参数。 此参数不应该是内容,但是您应该具有与所需行数一样多的参数。
在下面的示例中,调用使用3行-> 3个参数完成
osascript /Users/dwm8/Desktop/email.scpt "Test" "dwm8:test.pdf" "This is content of 1st line" "content of 2nd line" "test for the content of 3rd line"
在脚本开头的下方,该脚本可以读取所需的任意多个参数:
set theSubject to (item 1 of argv)
set theAttachmentFile to (item 2 of argv)
set theContent to ""
repeat with I from 3 to (count of argv)
set theContent to theContent & (item I of argv) & return
end repeat
然后,在Tell应用程序的“ mail”行中添加脚本的其余部分。 这样,您可以在调用oascript函数时决定如何在消息内容中分割行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.