无法使用AppleScript保存邮件附件

问题描述 投票:0回答:1

我尝试使用applescript保存附件,我的脚本在文件较小时(例如109字节)运行良好,但在附件太大时保存空文件(304KB)。我正在研究macOS High Sierra并且不知道如何修复它,任何人都有任何想法?

我的剧本:

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

谢谢

macos applescript
1个回答
1
投票

https://apple.stackexchange.com/a/322724/156892所述,更改:

save theAttachment in savePath

至:

save theAttachment in file savePath

另外,如果你像这样设置myPath,它会更强大:

set myPath to (path to downloads folder as text) 
© www.soinside.com 2019 - 2024. All rights reserved.