From 40tude Dialog Wiki

A script for playing .wavs when a new mail arrives, it can be modified to play a different .wav for each identity (see comments at the end of the script). Kudos go to J├╝rgen Haible for making it.

program OnEmailChecked;

function MessageBox( hWnd: LongWord; lpText, lpCaption: PChar;
                     uType: LongWord ): Integer;
                     external 'MessageBoxA@user32.dll stdcall';

function PlaySound( Filename: PChar; Options: LongWord ): Boolean;
         external 'sndPlaySoundA@winmm.dll stdcall';

procedure OnEmailChecked(Identity:string; FetchedCount,
TotalOnServerBefore, TotalOnServerAfter: integer);
var  s: String;
   if FetchedCount = 0 then exit; // no new mails

   PlaySound( 'c:\windows\media\tada.wav', 1 );

   s := 'Still none from Meg Ryan, but '
      + inttostr(FetchedCount) + ' from others!';
   MessageBox( 0, s, 'You''ve Got Mail!', $40 );


// It would be nice to be able to play a different sound depending on which
// Identity had mail.

//There's an "Identity" parameter in above event script, so you can use it
//to select the wanted file, e. g.:

   if Identity = 'this' then
      PlaySound( 'this.wav', 1 )
   else if Identity = 'that' then
      PlaySound( 'that.wav', 1 )
      PlaySound( 'others.wav' );