AppleScript in Mail: Save attachments with Save dialog
Hi everyone,
I am trying to create a Mail rule which executes an AppleScript. The script so far works fine, but only with a hardcoded path, in this example it's my Downloads folder:
using terms from application "Mail"
on perform mail action with messages theMessages for rule theRule
tell application "Mail"
repeat with oneMessage in theMessages
set {mail attachment:theAttachments} to oneMessage
repeat with oneAttachment in mail attachments of oneMessage
save oneAttachment in ("Macintosh SSD:Users:bjoern:Downloads:") & (name of oneAttachment)
end repeat
end repeat
end tell
end perform mail action with messages
end using terms from
I would now like to bring up a save dialog which asks for the folder to save to, but I already fail at my intermediary step of using a variable as the save path. This code works on its own:
set folderName to "Downloads"
set homePath to (path to home folder) as text
set saveFolder to homePath & folderName & ":"
If I run it, the result shows:
"Macintosh SSD:Users:bjoern:Downloads:"
But if I replace the hardcoded path with the variable saveFolder in my upper script, nothing happens.
Any ideas what I’m missing here?