I am having a problem with properly attaching a file to an email in a Perl script.  The file that I am attaching to each email is a simple tab delimited text file.  The problem is that the text file looks horrible because the columns don't line up evenly.  Because this is a "mass mailer" script that sends mail requesting that a bunch of people read the attachment and reply, it needs to be easy or people won't do it.  (It's a work thing...but where I work, people will simply ignore the message if there is anything more to it than double-clicking the attachment.)  So what I am trying to find out is how I can get a tab delimited excel spreadsheet into my emails; allowing the recipient to simply double-click the .xls file and pull up the information.

I have been dabbling with Spreadsheet::WriteExcel::Simple and toying with the MIME types set by MIME::Lite and I can't find the correct combination of the two.  What I typically end up with is a blah.xls file attached to the email and when you double-click it, you get the following error message:  "Unable to read file."

Any help/suggestions are greatly appreciated.  I apologize in advance if this is a newbie question.  I have only been doing Perl for about four months now.  Thanks.

-Scott


     Here is sample code -- I won't paste the entire script to save you the pain of having to read it all.  Notice the two lines where I have commented like this: " #<--- I don't know what to put here. "

~~~~~ BEGIN CODE SNIPPET ~~~~~

# Note that I am using the MIME::Lite module in this script to attach a file to a bunch of emails that I am sending out.

use MIME::Lite;

my $from_address = ' [EMAIL PROTECTED]';
my $to_address = '[EMAIL PROTECTED]';
my $subject = "yadda yadda yah";
my $mime_type = 'TEXT';  #<--- I don't know what to put here.
my $message_body = "$message";

# Create the initial text of the message
my $mime_msg = MIME::Lite->new(
   From => $from_address,
   To   => $to_address,
   Subject => $subject,
   Type => $mime_type,
   Data ="" $message_body
   )
  or die "Error creating MIME body: $!\n";

my $attachment = $filename;
my $recommended_filename = "something.xls";

# Attach the file
$mime_msg->attach(
   Type => 'text/plain',  #<--- I don't know what to put here.
   Path => $attachment,
   Filename => $recommended_filename,
   Disposition => attachment
   )
  or die "Error attaching test file: $!\n";
  
MIME::Lite->send('smtp', "mymailserver.mynetwork.com", Timeout=>60);
$mime_msg->send;         ### uses Net::SMTP <--- this line actually sends the email.

~~~~~ END CODE SNIPPET ~~~~~
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to