applescript - 删除特定邮箱中所有邮件中所有附件的最佳方法
问题描述
我完全是 AppleScript 新手,我正在尝试编写一个脚本,该脚本将删除指定邮箱 (Mail.app) 中所有邮件中的所有附件。
这是我正在尝试的:
tell application "Mail"
tell mailbox "Sent" of account id "<XXX>"
set ListMessage to get every message
repeat with aMessage in ListMessage
set aList to get every mail attachment of aMessage
repeat with aFile in aList
if (downloaded of aFile) then
delete aFile -- this gives an error
end if
end repeat -- next file
end repeat -- next message
end tell
end tell
运行它会导致错误:
Error: the Apple Event handler failed (errAEEventFailed:-10000)
我究竟做错了什么?
谢谢!
解决方案
事实证明,这delete
不适用于邮件附件,但有另一种解决问题的方法:您可以单击Remove Attachments
带有系统事件的菜单项:
tell application "Mail"
activate
every item of (get selection)
end tell
tell application "System Events" to click menu item "Remove Attachments" of menu "Message" of menu bar item "Message" of menu bar 1 of process "Mail"
推荐阅读
- java - 从 openJDK 8 升级到 openJDK 11
- java - 为什么当我尝试在它自己的类中创建一个对象时它显示stackoverflowerror?
- sbt - 什么优先于 SBT_OPTS 或 .sbtopts?
- blazor - 如何在 Blazor 中同步调用 HttpClient
- azure - 如何使用或访问 Azure AD 公开的 API(MyApis)?
- r - 在 Rcpp 中,如何使用声明为 Nullable 的变量?
- prometheus - 如何在每个时间窗口显示promethus + grafana的增加()函数结果
- javascript - 无法自定义 AWS SES 电子邮件模板
- ios - Flutter iOS:如何在 SelectableText 中公开“查找”工具栏选项?
- erlang - 如何让我的 Erlang 进程在选定的接口上运行?