Well, a couple minor things. Firstly, you didn't include the HTML file you use (file.html), which can make a difference. The problem might lie there. Specifically, with the syntax of the src="cid:img" references.
Also, you're manually embedding one header (Content-ID) within another. It should work the way you have it, but it is "more correct" to use the content_id parameter to Attach (see code below).
And though I'm sure it doesn't make any difference to the problem, you're giving the wrong content-type for the jpeg ('image/gif' instead of 'image/jpeg').
Here is your code, slightly modified and formatted, and the html file I used. It seems to work for me, though I don't actually have Outlook to test it with. As far as I can tell, this is "correct", though, so it should work the same with Outlook as with my email client (PocoMail). If this doesn't work with Outlook, then I can only assume the problem is with Outlook and printing inline images. Perhaps you could try it in another mail client to see if it's an Outlook-specific issue.
Update: There is a Knowledge Base Article (#287768) about this issue. You should check that to see if it's the same problem.
The code:
#!/usr/bin/perl
use warnings;
use strict;
use Mail::Sender;
my $sender = new Mail::Sender
{smtp => 'your-smtp-server', from => 'testing@example.com'};
if (ref $sender->OpenMultipart({
from => 'testing@example.com',
to => $to,
subject => 'mail message',
boundary => 'boundary-test-1',
multipart => 'related',
})) {
print "Attaching body...\n";
$sender->Attach({
description => 'html body',
ctype => 'text/html; charset=us-ascii',
encoding => '7bit',
disposition => 'none',
file => 'file.html',
});
print "Attaching jpeg...\n";
$sender->Attach({
description => 'file1.jpg',
ctype => 'image/jpeg',
encoding => 'base64',
disposition => 'inline; filename="file1.jpg";',
content_id => 'img1',
file => 'file1.jpg'
});
print "Attaching gif...\n";
$sender->Attach({
description => 'logo.gif',
ctype => 'image/gif',
encoding => 'base64',
disposition => 'inline; filename="logo.gif";',
content_id => 'img2',
file => 'logo.gif'
});
print "Closing / Sending\n";
$sender->Close() or die "Close failed! $Mail::Sender::Error\n";
} else {
die "Cannot send mail: $Mail::Sender::Error\n";
}
The file.html:
<html>
<body>
<p>Inline image number 1 (jpeg): <img src="cid:img1">
<p>Inline image number 2 (gif): <img src="cid:img2">
</body>
</html>
bbfu
Black flowers blossum
Fearless on my breath |