Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2024-03-28 12:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found