-- Download Apple Mail Messages -- https://c-command.com/scripts/eaglefiler/download-apple-mail-messages -- Summary: Fully download the selected messages from Apple Mail so that they can be imported. -- Requires: Apple Mail -- Install Location: ~/Library/Scripts/Applications/Mail/ -- Last Modified: 2020-11-21 tell application "Mail" with timeout of 60 * 60 seconds set _messages to the selection as list end timeout set _total to count of _messages set _secondsBetweenReports to 3 set _secondsUntilFirstReport to 0 set _atLeastOneReport to false set _lastReportDate to (my currentDate()) - _secondsBetweenReports + _secondsUntilFirstReport set _i to 1 repeat with _message in _messages try get _message's source -- download end try if (((my currentDate()) - _lastReportDate) > _secondsBetweenReports) or (_i is _total and _atLeastOneReport) then my notify(_i, _total) set _lastReportDate to my currentDate() set _atLeastOneReport to true end if set _i to _i + 1 end repeat end tell on notify(_i, _n) set _title to "Mail Download Progress" set _description to "Messages: " & _i & " of " & _n tell application "EagleFiler" notify with name _title title _title description _description end tell end notify on currentDate() --errAEPrivilegeError -10004 if call this from inside of "tell app 'Mail'" return current date end currentDate