我正在尝试在家庭网络上的 AppleScript 中设置监视文件夹。我希望脚本在文件(或多个文件)放入监视文件夹时生成一封电子邮件。我该如何实现?
答案1
保存如下脚本~/Library/Workflows/Applications/Folder Actions
:
on adding folder items to this_folder after receiving these_items
tell application "Mail"
tell (make new outgoing message)
make new recipient at end of to recipients with properties {address:"[email protected]"}
set subject to "subject"
set content to "content"
send
end tell
end tell
end adding folder items to
然后从文件夹操作设置中启用它:
或者如果您想将文件添加为附件,请在发送命令之前添加以下命令:
repeat with f in these_items
make new attachment with properties {file name:f} at after paragraph -1
end repeat
发送电子邮件的另一种方法是使用 msmtp。