#!/fellow/monks.pl
On a PC in a different part of the house, I wanted to know when new email arrived in my mailbox. I did not want to reconfigure Outlook for that. This simple perl script comes to the rescue.
It will sleep for the specified number of seconds, and then play the specified wav file when a new message arrives.
#!c:/perl/bin/perl.exe -w use strict; use Mail::POP3Client; use Win32::Sound; my $precnt = 0; if(!$ARGV[0] || !$ARGV[1] || !$ARGV[2] || !$ARGV[3] || !$ARGV[4]) { print "Usage : $0 [server] [username] [password] [sleep time] [wav + file]\n"; exit(1); } while(1) { &daemon($ARGV[0],$ARGV[1],$ARGV[2]); print "Sleep for $ARGV[3]\n"; sleep($ARGV[3]); } sub daemon { my ($server,$user,$pwd) = @_; my $pop = new Mail::POP3Client( USER => "$user", PASSWORD => "$pwd", HOST => "$server" ); my $cnt = $pop->Count; $pop->Close; if($cnt == -1) { print "Error in connecting to the POP3 server...\n"; return; } print "You have $cnt new messages\n"; if($cnt > $precnt) { Win32::Sound::Play("$ARGV[4]"); Win32::Sound::Stop; } $precnt = $cnt; }
Thanks!
|\/| _. _ _ ._
| |(_|_>_>\/| |
/
In reply to You've got mail! by Massyn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |