PDA

View Full Version : send a .zip file as an attachment in an email with Perl


crmpicco
11-22-2006, 04:58 PM
I have this code, and I am trying to send a .zip file as an attachment in an email
with Perl:

use MIME::Lite;

####### EMAIL #######
$msg = MIME::Lite->new(
From => "crmpicco\@picco.net (Picco)",
To => "craig\@tek.net",
Subject => "Properties",
Type => "multipart/mixed"
);

$msg->attach(Type => "TEXT", Data => "Attached to this email is a ZIP file");
$msg->attach(Type => "zip", Path => "/web/picco/data/crmpicco_111.zip", Filename => "crmpicco_111.zip");

$text = $msg->as_string;

$msg->send;

####### EMAIL #######

any help appreciated.

FishMonger
11-22-2006, 06:48 PM
Try changing the type:

$msg->attach(Type => 'x-gzip',

If that doesn't help, be more descriptive of the problem and include any error messages that you might be receiving.

crmpicco
11-23-2006, 09:06 AM
hi, i'll give that a go - but i'm not getting any error messages

crmpicco
11-23-2006, 09:50 AM
fully working code:

use MIME::Lite;

# send the zipped file in an attachment via email
####### EMAIL #######
$msg = MIME::Lite->new(
From => "crmpicco\@picco.net (Picco)",
To => "craig\@tek.net",
Subject => "Properties",
Type => "multipart/mixed"
);

$msg->attach(Type => "TEXT", Data => "Attached to this email is a ZIP file");
$msg->attach(Type => "application/zip", Path => "/web/picco/data/crmpicco_111.zip", Filename => "crmpicco_111.zip", Dispostion => "attachment");

$text = $msg->as_string;

$msg->send;

####### EMAIL #######