Der*_*ops 2 mac terminal.app apple-mail
我想从终端开始用 Mail.app 写一封电子邮件,并添加一个附件。像这样的东西:
macbook:~ me$ /Applications/Mail.app/Contents/MacOS/Mail -s the_subject -to email@domain.com < ~/Downloads/file.zip
Run Code Online (Sandbox Code Playgroud)
您可以使用 AppleScript 执行此操作。这是一个快速(经过快速测试)的 bash 脚本,它与您想要的很接近。
#!/bin/bash
echo "tell application \"Mail\"
activate
set MyEmail to make new outgoing message with properties {visible:true, subject:\"$2\", content:\"Some Message Here\"}
tell MyEmail
make new to recipient at end of to recipients with properties {address:\"$1\"}
make new attachment with properties {file name:((\"$3\" as POSIX file) as alias)}
end tell
end tell
" | osascript
Run Code Online (Sandbox Code Playgroud)
用法: compose_email 'email@domain.com' 'Some Subject' /path/to/attachment.zip
| 归档时间: |
|
| 查看次数: |
3147 次 |
| 最近记录: |