On Idle not working

It’s been a while since I’ve written anything in AS. I wrote this script this morning to notify me when I received email in my subfolders of Outlook 2011…it works except I can’t seem to get the idle functioning. Am I doing something wrong? ANy help would be appreciated:

on idle

display notification "Checking Outlook mail"

tell application "Microsoft Outlook"
	
	if view of the first main window is not equal to "mail view" then
		set view of the first main window to mail view
	end if
	
	set mailFolder to mail folder of exchange account "xxxxxxxxxxxx"
	
	repeat with thisFolder in mailFolder
		if name of thisFolder is "People" then
			set peopleFolders to every mail folder of thisFolder
			
			repeat with thisPeopleFolder in peopleFolders
				set senderName to name of thisPeopleFolder
				
				set messageCount to count of every message of thisPeopleFolder
				
				if messageCount > 0 then
					set thisMessage to last message of thisPeopleFolder
					
					if is read of thisMessage is false then
						set messageTitle to subject of thisMessage
						
						display notification "Message from: " & senderName & return & "Subject: " & messageTitle
						delay 7
						
					end if
				end if
			end repeat
			
		end if
	end repeat
	
	return 10
	
end tell

end idle

Hi.

Did you save it as a stay-open application? (Choose “Application” in the pop-up menu at the bottom of Script Editor’s “Save As .” dialog and check the “Stay open after run handler” option below that.)

Thanks, that was it. Been a while since I wrote one of these. :slight_smile: