#!/bin/zsh -f

function turnOffMailboxRule {
echo "starting at `date`"
osascript <<-EOF1
--tell application "Finder"
--	activate
--	activate "Mail"
	tell application "Mail"
		activate
		activate rules
		set enabled of rule "makemailbox" to false
--	end tell
end tell
EOF1
print "turned off makemailbox rule at `date`"
}

function getMail {
osascript <<-EOF2
-- tell application "Finder"
--	activate
	tell application "Mail"
		activate
        check for new mail
--	end tell
end tell
EOF2

print "Done downloading my mail at `date`"
}

function turnOnMailboxRule {
osascript <<-EOF3
-- tell application "Finder"
--	activate
--	activate "Mail"
	tell application "Mail"
		activate
		activate rules
		set enabled of rule "makemailbox" to true
--	end tell
end tell
EOF3

print "turned on makemailbox rule at `date`"
}

turnOffMailboxRule; getMail ;turnOnMailboxRule