MIME::Lite HTML message handling

J

John B. Kim

I am working on the code below:
******************************************************
use strict;
use MIME::Lite;
use Net::SMTP;
my $from = '(e-mail address removed)';
my @addweek1 = qw([email protected]
(e-mail address removed)
);
my $Fnameweek1 = 'JNIssue11.pdf';
my $subject='Issue 11';
my $message = 'C:\\message1.html';
for my $address (@addweek1) {
my $msg = MIME::Lite->new (
From => $from,
To => $address,
Subject => $subject,
Type =>'multipart/related');

$msg->attach (
Type => 'text/html',
Data => qq{$message});

$msg->attach (
Type => 'x-pdf',
Path => "c:\\guide\\JNIssue11\\$Fnameweek1",
Filename => $Fnameweek1);
MIME::Lite->send('smtp', 'smtp.earthlink.net');
$msg->send();
}
***************************************
The above codes attach the pdf file I have in my hard drive and send the
email to multiple recepients with pdf attachments. Now I use this codes to
send messages with different attachments and different HTML messages to the
same group of recipients. With the codes above I can just change the name
and location of new attachment with different version of emailing, but for
now I have to always copy and paste lengthy html message after qq{..

What I would like to realize is through my $message = 'C:\\message1.html', I
wish qq{$message reads the contents of c:\message1.html.

However, when I run the above codes, rather than seeing the html message in
the email body, I just see c:\message.html in the body of the email sent.

It probably is something simple for an experienced Perl programmer, but as a
beginer, I cannot figure what to put after Data => qq{ so that the content
of c:\message.html be place as email body.

Any help will be deeply appreciated. I hope my message is clear enough so
that people understand what I am struggling about.
 
J

Joe Smith

John said:
my $message = 'C:\\message1.html';
...
$msg->attach (
Type => 'text/html',
Data => qq{$message});

Have you tried changing that to
Path => $message,
Filename => $message;


-Joe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,783
Latest member
RickeyDort

Latest Threads

Top