简体   繁体   English

无法使用applescript保存邮件附件

[英]Failed to save mail attachments using applescript

I try to save attachments using applescript, my script works well when the files are small (eg 109 Bytes) but save empty file when the attachment is too large (304KB). 我尝试使用applescript保存附件,当文件较小(例如109字节)时,脚本运行良好,但是当附件太大(304KB)时,保存空白文件。 I'm working on macOS High Sierra and had no clue how to fix it, anyone got any idea? 我正在研究macOS High Sierra,不知道如何解决它,有人知道吗?

My acript: 我的标题:

 using terms from application "Mail" on perform mail action with messages theMessages set myPath to "Macintosh HD:Users:MY_USER:Downloads:" tell application "Mail" repeat with eachMessage in theMessages repeat with theAttachment in eachMessage's mail attachments set originalName to name of theAttachment set savePath to myPath & originalName try save theAttachment in savePath end try end repeat end repeat end tell end perform mail action with messages end using terms from 

Thanks 谢谢

As mentioned in https://apple.stackexchange.com/a/322724/156892 , change: https://apple.stackexchange.com/a/322724/156892中所述 ,更改:

save theAttachment in savePath

to: 至:

save theAttachment in file savePath

In addition, it would be more robust if you set myPath like so: 另外,如果这样设置myPath,它将更加健壮:

set myPath to (path to downloads folder as text) 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM