Hi;

I have written a small email program which sends a simple email body
which is "Test Text" and an attachment file whose name is test.htm.
But I don't know how I can put the content of test.htm directly into
the email's body and send it instead send the file via attaching. If
you know it, would you please kindly tell me?

Below I have attached the small perl program for your reference.

use MIME::QuotedPrint;
use MIME::Base64;
use Mail::Sendmail 0.75;
use HTML::Entities;

%mail = (
         from => '[EMAIL PROTECTED]',
         to => '[EMAIL PROTECTED]',
         subject => 'Test',
        );


$boundary = "====" . time() . "====";
$mail{'content-type'} = "multipart/mixed; boundary=\"$boundary\"";

$message = encode_qp( "Test Text" );

$emailfilename="test.htm";
open (EMAILFILE, $emailfilename) or die "Cannot read $file: $!";
binmode EMAILFILE;
local $/ = undef ;
$mail{body} = encode_base64(<EMAILFILE>);
close EMAILFILE;

$boundary = '--'.$boundary;
$mail{body} = <<END_OF_BODY;
$boundary
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

$message
$boundary
Content-Type: application/octet-stream; name="test.htm"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="test.htm"

$mail{body}
$boundary--
END_OF_BODY

sendmail(%mail) || print "Error: $Mail::Sendmail::error\n";

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to