Default Schedule Wifi connection and Outlook Send/Receive?

I don't have a data plan, but work in a location that has wifi. Is there a program that every x hours will attempt to connect to the closest wifi network and, upon connection, pull my mail from Outlook/Gmail?

Thanks.