有两种方法可以做到这一点:
AppleScript
框架
NSSharingService
NSSharingService 撰写邮件:
let service = NSSharingService(named: NSSharingServiceNameComposeEmail)
service?.recipients = ["test@gmail.com"]
service?.subject = "Test Mail"
service?.performWithItems(["Test Mail body"])
Run Code Online (Sandbox Code Playgroud)
启动邮件应用程序
如果您只想打开Mail
应用程序,请尝试以下代码:
NSWorkspace.sharedWorkspace().launchApplication("Mail")
Run Code Online (Sandbox Code Playgroud)
设置不当:
从终端尝试:
您可以使用 shell 脚本使用本机客户端发送邮件
mail -s "Hello" "test@gmail.com" <<EOF
Hello, Test!
EOF
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1265 次 |
最近记录: |