HI --

Has anyone had a similar problem when sending email with attachments?? 

Thanks

Mike


-----Original Message-----
From: Mike Rapuano 
Sent: Thursday, August 23, 2001 2:07 PM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]; Mike Rapuano
Subject: Sending emails: Question <newbie>


Hi all -- 

I'm trying to send an email with an attachment from the below code (Gary
MacDonald posted the code on activestate. Thanks Gary:-). The code works
fine to send email to my Imail Server (type of nt mail server) but when
I try to send a message to either ny yahoo mail account or my exchange
mail server "I don't get the body of the message OR the attachment". 

Any suggestion would be greatly appreciated.

Thanks

Mike





use Net::SMTP; 
use MIME::Base64; 


my $file = 'test.doc';
my $mediatype = 'msword'; 
open INPUT, $file or die "Can't open INPUT file $file: $!\n"; 
binmode INPUT; 
my $buffer; 
# 
my $from = '[EMAIL PROTECTED]'; 
my $to = '[EMAIL PROTECTED]'; 
my $server = 'smtp.server.com';
 
# 
my $smtp = Net::SMTP->new($server) or die "Can't create SMTP object\n"; 
# 
$smtp->mail($from); 
$smtp->to($to); 
# 
my @msg = <<MSG; 
From: $from 
To: $to 
Subject: word document attachment 
MIME-Version: 1.0 
Content-type: multipart/mixed; boundary="Boundary $time" 

--Boundary $time 
Content-type: text/plain 

This is a test email.....


--Boundary $time 
Content-type: application/$mediatype; name="$file" 
Content-disposition: attachment; filename="$file" 
Content-transfer-encoding: base64 

MSG


# 
$smtp->data(); 
$smtp->datasend(@msg); 
$smtp->datasend(encode_base64($buffer)) while(read (INPUT, $buffer,
60*57));
$smtp->datasend("\n--Boundary $time--\n"); 
$smtp->dataend(); 
$smtp->quit(); 
# 
close INPUT; 




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to