#!/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!
|\/| _. _ _ ._
| |(_|_>_>\/| |
/
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: You've got mail!
by bgreenlee (Friar) on Jul 25, 2004 at 17:00 UTC | |
|
Re: You've got mail!
by graff (Chancellor) on Jul 25, 2004 at 14:24 UTC | |
by naChoZ (Curate) on Jul 27, 2004 at 01:20 UTC | |
|
Re: You've got mail!
by CountZero (Bishop) on Jul 25, 2004 at 16:05 UTC | |
|
Re: You've got mail!
by chanio (Priest) on Jul 26, 2004 at 04:35 UTC |