Preview:
getLastReceivedEmail: function(target) {
		var mail = new GlideRecord('sys_email');
		mail.addQuery('instance',target);
		mail.addQuery('type', 'received');
		mail.orderByDesc('sys_created_on');
		mail.setLimit('1');
		mail.query();
		if(mail.next()){
			return mail.sys_id;
		}
		else
			return;
	},
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter