Was browsing and really appreciate the script. Added a bit to it for enumerating the files listed. Hopefully this code works for others.
set filelist to "{query}"
set oldDelimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to " "
set theArray to every text item of filelist
set AppleScript's text item delimiters to oldDelimiters
set itemList to "Attachments" & return
set theCount to 0
if length of theArray is greater than 1 then
repeat with eachitem in theArray
set theCount to theCount + 1
try
set oldDelims to AppleScript's text item delimiters -- save their current state
set AppleScript's text item delimiters to {"/"} -- declare new delimiters
set itemList to itemList & theCount & ". " & the last text item of eachitem & return
set AppleScript's text item delimiters to oldDelims -- restore them
on error
set AppleScript's text item delimiters to oldDelims -- restore them in case something went wrong
end try
end repeat
else
set eachitem to item 1 of theArray
set theCount to theCount + 1
try
set oldDelims to AppleScript's text item delimiters -- save their current state
set AppleScript's text item delimiters to {"/"} -- declare new delimiters
set itemList to itemList & theCount & ". " & the last text item of eachitem
set AppleScript's text item delimiters to oldDelims -- restore them
on error
set AppleScript's text item delimiters to oldDelims -- restore them in case something went wrong
end try
end if
tell application "Mail"
activate
tell (make new outgoing message at end of outgoing messages with properties {visible:true, subject:"- - ATTACHMENT(S) ENCLOSED ", content:itemList & return})
repeat with eachitem in theArray
set t to POSIX file eachitem
make new attachment with properties {file name:t as alias} at after last paragraph
end repeat
end tell
end tell