help on a mail notifier

I’ve been working on a mail notifier for Mail.app and this is what i’ve got:

tell application "Mail"
	activate
	check for new mail
	if number of messages is less than "1" then
		display dialog "You have no new mail"
	end if
	if number of messages is greater than "0" then
		set msgNumber to number of messages
		display dialog "You have " & msgNumber & " new message(s)!"
	end if
end tell

does anybody know how to fix it? it doesn’t seem to work

Try:


tell application "Mail"
	check for new mail
	set total to 0
	repeat with theAccount in (every account)
		repeat with theBox in (every mailbox of theAccount)
			set total to total + (count (messages in theBox where read status is false))
		end repeat
	end repeat
	if total is 0 then
		set r to "No new messages"
	else if total > 0 then
		if total is equal to 1 then
			set m to "message"
		else if total > 1 then
			set m to "messages"
		end if
		set r to "You have " & total & " new " & m
	end if
	return r
end tell

works great! thanks :smiley: