Saving a Mail Attachment

Hello, I am hoping someone can help me. I am trying to create a very simple script to save the mail attachment from a mail message into a specific folder. This script is invoked by a mail rule and there is always only one attachment and I want it always saved in the same folder, so very simple… BUT I can’t get it to work. I have found numerous examples of more complicated routines which purport to do the same thing but can’t get any off them to work either… This is my first AppleScript so I am an admitted novice but I have invested over 20 hours trying to get this thing to work… For simplicity I have stripped this down to the bare minimum code which I think I need to have to get it to work but still receive an error. Any help or suggestions would be greatly appreciated…

Tim

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
using terms from application "Mail"
          on perform mail action with messages theMessages for rule theRule
               save mail attachment in "Macintosh HD:Users:Tim:Dropbox:Tim & Jolene:Wirecard:"
         end perform mail action with messages
end using terms from

Here is my sample code for doing this.

Two things I notice in your code:

  1. You don’t include the message and the mail attachment (messages may have many attachments) to be saved.
  2. You are specifying the save location as a string when it needs to be a file or posix path value instead.