Save Mail attachments to a folder
I modified a published script and it used to work, but it's no longer working in Sierra.
using terms from application "Mail"
on perform mail action with messages theMessages for rule theRule
-- set up the attachment folder path
tell application "Finder"
set folderName to "Dropbox/ GPX daily logs/2017 MotionX"
set homePath to (path to home folder as text) as text
set attachmentsFolder to (homePath & folderName) as text
end tell
Latest version of Sierra.
tell application "Mail"
repeat with eachMessage in theMessages
--set the sub folder for the attachments to the senders mail address.
-- All future attachments from this sender will the be put here.
-- set subFolder to (sender of eachMessage)
-- set up the folder name for this mail message's attachments. We use the time stamp of the date received time stamp
set {year:y, month:m, day:d, hours:h, minutes:min} to eachMessage's date received
---set timeStamp to (y & "-" & my pad(d) & "-" & my pad(m as integer) & "_" & my pad(h) & "-" & my pad(min)) as string -- month as number
set timeStamp to (y & "_" & my pad(d) & "-" & m & "_" & my pad(h) & "-" & my pad(min)) as string
try
-- Save the attachment
repeat with theAttachment in eachMessage's mail attachments
set originalName to timeStamp & "_" & name of theAttachment
set savePath to attachmentsFolder & ":" & originalName
try
save theAttachment in file (savePath)
end try
end repeat
on error msg
display dialog msg
end try
end repeat
end tell
end perform mail action with messages
end using terms from
on pad(n)
return text -2 thru -1 of ("0" & n)
end pad
OP here. But I think the problem is that I used a slash instead of a colon for the path separator.
最後更新:2017-08-23 00:44:35
上一篇:
Extension conversion issues on Sierra
下一篇:
Stray email Address on screen IOS Sierra
Restore Keychain
Remote lockout reset
Everything that broke after updating to WatchOS 4
external hard drives not showing up in Finder s...
Is an Apple Watch series 1 compatible with an i...
Time Machine and Mac Pro
My iPad won’t accept my Apple ID password
Turn off iMessages on mac, Turn off iMessages o...
There is black dialogue box on my mac mini that...
apple hardware test returned an error code:
相關內容
"com.apple.installer.pagecontroller error
any idea what error 3503 is?
Underallocation Detected on Main device
The operation couldn’t be completed. (BKA...
is ctoid.exe a virus on my ipad safari browser?
iTunes Error: Declined to authorize this image ...
Keep High Efficiency Original if Available Chec...
iTunes 12.7 cannot edit playlist
High Sierra Stuck & Decryption paused
Need to unlock iphone 5 to reactivate the phone...
熱門內容
Christian Music Removed From Itunes
I'm being billed twice every month for Apple Mu...
iMac running slow
Fix disappearing album art after moving iTunes
Activation Locked iWatch
Can I change the iwatch to miles instead of kil...
I keep seeing the "You don't have permission to...
can't read any menus macbook air
iPad 2, iOs9.3, taking days to restore
charges made under itune memeberships