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


In reply to Re: Sending Inline Images in e-mail with Mail::Sender (or getting them to print in Outlook) by bbfu
in thread Sending Inline Images in e-mail with Mail::Sender (or getting them to print in Outlook) by vroom

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.