Re: Perl Script to send mail with Attachment

2004-05-14 Thread Alexander Apprich
Hi Satish,

Satish Kumar wrote:
Hi ScriptKings,
 
Im a newbie in Perl,
 
Would like to know following Info:
 
Can we create
 
*Perl Scipt to send Mails with Attachments*
 
Any Tips, Help, Code,Suggestions & Guidance are Welcome
 
The module Mail::Sender is probaply what you are looking for...

This is a subroutine I use to send a logfile from a Windows-Box.

sub SendMail {
  # What mail error or okay?
  my ( $Action );
  ( $Action )  =  @_;
  if ( $Action eq "ERROR" ) {
$note = "ALERT: blablabla";
  } elsif ( $Action eq "OKAY" ) {
$note = "NOTE: blablabla";
  }
  $Msg = "See attached file for more details.\n";
  if ( $Sender = Mail::Sender->new( {smtp => 'scmail',
 from => 'serv-int'} ) ) {
  } else {
End ( "FAILED" );
  }
  if ( $Sender->MailFile( { to  => 'apprich',
subject => "$note",
msg => "$Msg",
file=> "$LogFile"} ) ) {
  }
}

 
Regards,
Satish
HTH

Alex
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Perl Script to send mail with Attachment

2004-05-14 Thread Wenjie Wang



Try 
this:
  $mailer = MIME::Lite->new( 
   From => 
$from,    
To   => $to, 
   Subject  => $subject, 
   Type => 
'multipart/mixed'   ); 

 
  $mailer->attach(Type =>'TEXT', Data ="" 
$emailbody);
 
$mailer->attach(Type 
=>'TEXT',    Path  => 
$anAttachment,    Disposition => 
'attachment',    
);
  $mailer->send('smtp', $ENV{SMTP_SERVER}, 
Timeout=>60);
--Wenjie 
Wang(a.k.a. William)    [EMAIL PROTECTED]WANG Infonology 
Systems  Ph:(02)-98712018; mob:0412688380http://users.bigpond.net.au/WISeAgent==This 
e-mail is confidential and may contain legally privileged information.  You 
should not disclose its contents to any other person.  If you are not the 
intended recipient, please notify the sender immediately.Whilst every 
reasonable precaution has been taken to minimise the risk of computer software 
viruses, it cannot accept liability for any damage which you may sustain as a 
result of such viruses.  You should carry out your own virus checks before 
opening the e-mail (and/or any attachments).
 
 
 
 
 -Original Message-From: 
[EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED]On Behalf Of 
Satish KumarSent: Friday, 14 May 2004 9:26 PMTo: 
[EMAIL PROTECTED]Subject: Perl Script to send 
mail with Attachment

  Hi ScriptKings,
   
  Im a newbie in Perl, 
   
  Would like to know following Info:
   
  Can we create 
   
  Perl Scipt to send Mails with Attachments
   
  Any Tips, Help, Code,Suggestions & Guidance are Welcome
   
   
  Regards,Satish
   
  
  
  Do you Yahoo!?SBC 
  Yahoo! - Internet access at a great low 
price.
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs