On 11/17/2006 09:07 AM, Zembower, Kevin wrote:
I'm trying to send an HTML (boss' demand) using MIME::Lite. The program
I'm using is pasted in below my signature. When I comment out all the
'$msg->attach' lines, the body of the email message appears as HTML in
my Outlook email reader. As soon as I uncomment just one of the
'$msg->attach' lines, both the new attachment and the file 'index.htm'
appear as attachments, and the body of the email appears blank.

Is this behavior just an artifact of the way Outlook displays it? Can
this behavior be controlled, to put the file 'index.htm' in the body and
attach the images?

Thanks a lot for all your help and advice.

-Kevin

Kevin Zembower
Internet Services Group manager
Center for Communication Programs
Bloomberg School of Public Health
Johns Hopkins University
111 Market Place, Suite 310
Baltimore, Maryland  21202
410-659-6139 ============================================================
#! /usr/bin/perl -w
#
#This program takes a list of email addresses and emails them.
#NOTE: This program must be changed for each edition of the newsletter
#

use strict;

use MIME::Lite;

while (<>) {
   my $msg = MIME::Lite->new(
          To     =>"$_",
          Subject =>'New phase of funding to support life-saving
vaccines',
          Type    =>'text/html',
          Path    =>'index.htm',
          );
#$msg->attach(Type =>'text/html', Path =>'index.htm');
   $msg->attach(Type =>'image/jpg', Path =>'index_files/Hivheader1.jpg',
Disposition=>'attachment');
   #$msg->attach(Type =>'image/jpg', Path =>'index_files/image001.jpg',
Disposition=>'attachment');
   #$msg->attach(Type =>'image/jpg', Path =>'index_files/image002.jpg',
Disposition=>'attachment');
   #$msg->attach(Type =>'image/gif', Path =>'index_files/image003.gif',
Disposition=>'attachment');
   #$msg->attach(Type =>'image/jpg', Path =>'index_files/image004.jpg',
Disposition=>'attachment');
   #$msg->attach(Type =>'image/jpg', Path =>'index_files/image005.jpg',
Disposition=>'attachment');
   #$msg->attach(Type =>'image/jpg', Path =>'index_files/image006.jpg',
Disposition=>'attachment');
$msg->send("sendmail","/usr/bin/qmail-inject");
}; #while there are more address on the command line


I don't have Outlook. When I disable viewing attachments inline, and I specify the data to MIME::Lite using Path => '...', I get the same results in Thunderbird as you do in Outlook (the HTML part is not displayed).

However, if I specify the data using Data => '...', the HTML code is viewable in Thunderbird.

use strict;
use MIME::Lite;
use File::Slurp;

die ("No source address") unless $ENV{SRCADDR};
die ("No destination addresses") unless $ENV{DSTADDR};

while ($ENV{DSTADDR} =~ m/([^:]+)/g) {
    my $To = $1;
    my $mime = MIME::Lite->new(
        From => $ENV{SRCADDR},
        To => $To,
        Subject => 'MIME::Lite test message',
        Type => 'text/html',
        # Path => 'index.htm',
        Data => scalar(read_file('index.htm')),
        );

    die ("object creation failed") unless $mime;

    $mime->attach(Type => 'image/png', Path => 'image-2.png');

    $mime->send();
}


__END__

Note, when I enable viewing attachments inline in TB, I can see the HTML text even when I use the Path => '...' .




--
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