#!/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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.