[sf-perl] MIME::Lite

Peter Loo loopeter at yahoo.com
Thu Jul 23 15:06:47 PDT 2009

Hello All,
The Sun OS server that I am currently developing on has MIME::Lite 3.01 installed on it.  I have search all over the Internet for a sample code that shows a way to mail an Excel file as an attached file.  I found a few sample codes and they all successfully send the test files (*.pdf, *.xls, *.txt, *.pl, *.jpg, *.gif, *.zip) to my Exchange email account, however, when I attempt to open these files, not one will open successfully.  For example, the JPG and GIF files show no image.  The .pl file shows as binary un-readable view.  The Excel file spits out the error (This file is not in a recognizable format.).  The PDF file reports (Adobe Reader could not open 'Review.pdf' because it is either not a supported file type or because the file has been damaged.)
I FTPed to the server and downloaded the files to my PC and was able to open all the files successfully but through MIME::Lite, I can't.
I have changed the settings around in program but no luck.  Will you kindly look at the code and advise as to what I might be doing wrong?
Here is my sample program:
  use MIME::Lite;
  #my $fileName = "debug_20090302.xls";
  #my $fileName = "Review.pdf";
  #my $fileName = "APR_09_DUAL_OP_CK.xls";
  #my $fileName = "LG_enV_Touch_lowres_270x191.jpg";
  #my $fileName = "p.pl";
  my $fileName = "stravinsky09.gif";
  my $datDir = "/the/path/to/my/file";
  my $msg = "My message goes here";
  my $body = "Your reprot is attached herewith.";
  my $message = MIME::Lite->new( From     => 'someone at domain.com',
                                 To       => 'someone_else at some_other_domain.com',
                                 Subject  => $msg,
                                 #Type     => 'text/plain',
                                 Type     => 'multipart/mixed' );
                                 #Encoding => '8bit',
                                 #Data     => $body );
                                 #Data     => "Dear Sirs,\nBest regards,\nbla bla" );
  #my ($mime_type, $encoding) = ('application/octet-stream', 'base64');
  $message->attach ( Type     => 'TEXT',
                     Data     => "Here's the GIF file you wanted"
  #$message->attach ( Type     => 'application/octet-stream',
  #$message->attach ( Type     => 'application/vnd.ms-excel',
  #$message->attach ( Type     => 'application/jpeg',
  #$message->attach ( Type     => 'application/pdf',
  $message->attach ( Type     => 'application/gif',
                     Path     => $datDir,
                     #Encoding => 'base64',
                     Filename => $fileName,
                     Disposition => 'attachment' );



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/sanfrancisco-pm/attachments/20090723/aa2cd9c3/attachment.html>

More information about the SanFrancisco-pm mailing list