Applescript to work with mail and delete messagess without content

The new trick with spam is to send a message with only images that have embedded links and no text that mail rules can trigger on. I’m Getting sick of this spam. I worked with rules but there is no ability to trigger on a message with “no content” or “no text”.
Can anyone point me in the direction that tells a mail message to run an applescript (I know how to do this) and check the message for no content or only images, then delete the message.

If you need clarification, I can rewrite this post.

Thank you,

dishusa

In what form this images contain the URLs? Without providing example it is difficult to help you. It is QR code images? You can provide screenshot at least?

you can send spam-message to my mail “kniazidis.rompert@gmail.com

I sent you an example of the spam email to your gmail account.

Let me know if it was received.

No any message received from you. But I created test messages and sent them to myself successfully. Then I filtered them with following rule condition:


using terms from application "Mail"
	on perform mail action with messages these_messages for rule this_rule
		tell application "Mail"
			repeat with eachMessage in these_messages
				tell aMessage's content to set |contents| to {color, font, size}
				if |contents| is {missing value, missing value, 0.0} then delete (contents of eachMessage)
			end repeat
		end tell
	end perform mail action with messages
end using terms from

I named script as CheckEmptyContent.scpt and saved it to ~/Library/Application Scripts/com.apple.mail/ folder. Then I created one rule for Every message with Run Script “CheckEmptyContent”, and it worked. The spam messages was deleted by the rule not immediatelly, but after some time.

Thank you,

One thing I cannot figure out in Mail Rules is how to create a rule that triggers on “every message”

Can you help there? I cannot find that condition in the Rules.

https://macscripter.net/viewtopic.php?id=48283

Post no 2

Unfortunately, I cannot get the applescript portion to work. I used it exactly as written and it does not process the messages.

Post #2 of other topic, indicated by other user, is for messages chosen manually. As I understand, you asked for other thing - you asked for mail rule. So, create the rule manually, attach to it my script from post #4 of current topic.

Go Mail → Preferences → Rules → Add Rule. Add following rule, confirm to apply it (not for chosen messages):