Add Attachment to Mail using AppleScript Studio

I’m modifying the Mail Search example provided with Xcode to check my mailboxes for messages that fit specific characteristics. One of those is whether there is an attachment in the message.

Does anyone know how to check for attachments in a Mail message using the provided library in AppleScript? I tried

set hasAttachment to {}
set hasAttachment to hasAttachment & every attachments in content in m
– where m is a message in the mailbox

Any thoughts?

:lol:

You can use your own variations of the following handler, which returns a list with all the attachments. If there are no attachments, the list is empty:


tell application "Mail"
	set myMsg to message 1 of inbox
	tell myMsg
		set myList to attachments of content
		return myList
	end tell
end tell