Sun messenger express delete all messages in inbox: applescript + javascript

Alec Jacobson

October 25, 2009

weblog/

I recently received a notice that I had filled my email storage quota for my NYU email account. About a month or two ago I set up my gmail account to fetch my NYU account mail, so all my emails are backed up with google. I logged into NYU Home's webmail client (Sun Java™ System Messenger Express) and was dismayed to find out that the only way to delete all the messages in my inbox was to select "all" 20 messages and hit delete over and over again (see update below). I tried going to the Folders tab, selecting Inbox and clicking delete but I got this error: "System folders - cannot be deleted". It seems impossible to purge your inbox using the "Mess Express". Since applescript can tell Safari to run arbitrary javascript on an open webpage, I hunted (rather painfully, "Mess Express" is about 10 html frames within frames, no objects have ids and the js is split between many files) through the source and found the necessary functions to automate deletion. Here's my applescript. Before running you should have signed into you messenger express client and be viewing your inbox in the frontmost Safari window:
tell application "Safari"
	set doc to front document
	repeat (4945 / 20) times
		repeat until source of doc contains "</html>"
			delay 1
		end repeat
		do JavaScript "parent.mailFrame.selectAll('true');" in doc
		do JavaScript "parent.mailFrame.delmsg();" in doc
		delay 1
	end repeat
end tell
Note: Replace 4945 with the total number of messages you need to delete. After the script has successfully finished (it should take less than 2 seconds per 20 emails deleted), click on the Folders tab at the top,

folder tab link

then hit Empty Trash. empty trash If there is an easier way to delete all messages in your inbox, I'd love to know. Update: It is possible to speed this up even more by setting the message view count from 20 to 100 by clicking on the Options tab then selecting Appearance and changing the Message List View amount to 100.

messenger express appearance options