Advertisement
mdelatorre

Applescript to auto save mail attachment in Apple Mail

Sep 5th, 2020
7,113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Tested on macOS 10.13.6
  2.  
  3. use AppleScript version "2.4"
  4. use scripting additions
  5.  
  6. using terms from application "Mail"
  7.     on perform mail action with messages messageList in mailboxes mbox for rule aRule
  8.        
  9.         --  Save on DesktopPath    
  10.         set desktopPath to (path to desktop) as string
  11.        
  12.         tell application "Mail"
  13.             set selectedMessages to the selection
  14.             repeat with aMessage in selectedMessages
  15.                 repeat with anAttachment in mail attachments of aMessage
  16.                     set attachmentName to name of anAttachment
  17.                     save anAttachment in file (desktopPath & attachmentName)
  18.                    
  19.                 end repeat
  20.             end repeat
  21.         end tell
  22.        
  23.     end perform mail action with messages
  24. end using terms from
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement