Mail.app Save Attachments to a Desktop Folder

Hi folks. I’m looking for a solution for the following:

Select my Junkie spam smart folder (multiple accounts) and save all attachments into a new desktop folder called “attachments”.

I tried Automator but it doesn’t have the ability to select that specific smart folders, as this type is not available.

Screenshot 2023-03-05 at 4.40.17 PM

So back to Script Editor.

How can I select that smart mailbox, then save attachments from the whole set? This is what I have, which doesn’t work:

tell application "Mail"
  set selectedMailbox to mailbox "Junkie" of account "House"
  set selected messages of message viewer 1 to {}
  set selected mailbox of message viewer 1 to selectedMailbox
end

It trips on the last instruction. “A class name can’t go after this identifier.