Send Email with the Spawn Command
Previous Topic  Next Topic 

Purpose

 

This example Perl program shows how NetMailBot can be invoked from within Perl using Perl's Spawn command.

 

Additional Prerequisites

 

Using this feature requires knowledge of the Perl programming language and a working installation of Perl on your computer.

 

Prepared Example Files

 

 

The archive contains one file:

 

 

Perl File Contents

 

This is the content of the Perl file:

 

#!/usr/bin/perl -w

use strict;

 

my $Pid;

my $executable = 'NetMailBot.exe';

my $server = 'mail.domain.com';

my $from = 'to@domain.com';

my $to = 'from@domain.com';

my $subject = 'Test: Perl Spawn Command';

my $body = "Test: Perl Spawn Command";

 

my $Args = '-server ' . $server . 

                  ' -from ' . $from .

                  ' -to ' . $to . 

                  ' -subject ' . '"' . $subject . '"' . 

                  ' -body ' . '"' . $body . '"';

 

Win32::Spawn( $executable, $Args, $Pid );

 

if ($Pid) 

{

   print "Process started with PID ", $Pid , "\n";

}

else 

{

   print "Unable to start process: ", Win32::FormatMessage( Win32::GetLastError() ), "\n";

}