Here's a script that may do something close enough to what you wanted, using "gui" scripting (slow and clunky, but apparently the only option here):
This could probably be improved by possible integration with VikingOSX's pdf merging script, should he choose to post that.
-- saves selected Mail message as pdf
set saveFolderPath to "~/Desktop/"
tell application "Mail"
set theSel to selection
set theMessage to item 1 of theSel
activate -- needed for gui-scripting
--print the message to pdf
tell application "System Events"
tell process "Mail"
click menu item "Print…" of menu "File" of menu bar 1
repeat until exists sheet 1 of window 1
delay 3 -- increase if needed
end repeat
tell splitter group 1 of sheet 1 of window 1
click menu button "PDF"
click menu item "Save as PDF" of menu 1 of menu button "PDF"
end tell
repeat until exists button "Save" of sheet 1 of sheet 1 of window 1
delay 0.02
end repeat
keystroke "g" using {command down, shift down}
repeat until exists combo box 1 of sheet 1 of sheet 1 of sheet 1 of window 1
delay 0.02
end repeat
tell sheet 1 of sheet 1 of sheet 1 of window 1
set value of combo box 1 to saveFolderPath
click button "Go"
end tell
click button "Save" of sheet 1 of sheet 1 of window 1
delay 0.5
repeat while exists button "Cancel" of sheet 1 of window 1
delay 0.2
end repeat
end tell
end tell
-- save the attachments -- (only need this if they are not visible inline?)
repeat with anAttachment in mail attachments of theMessage
-- set attachName to name of anAttachment
try
save theAttachment in POSIX file saveFolderPath
end try
end repeat
end tell
Tested in Big Sur 11.4, Apple Mail 14.0. The 'delay' times may need tweaking on other machines.
SG