develooper Front page | perl.pep | Postings from November 2014

Where is the attached file opened with Email::MIME?

Thread Next
From:
Octavian Rasnita
Date:
November 15, 2014 22:51
Subject:
Where is the attached file opened with Email::MIME?
Message ID:
054E23F59122437B9B1355DE9D9C4286@octavianf303f0
Hello,

I couldn't find a way of using Email::MIME::Kit to compose a message by 
adding the file attachments on the fly that allow adding more or less files 
for different recipients, so I am trying to use Email::MIME for this.

But I found that Email::MIME brokes the pdf file attachments by increasing 
their size.
I use the code below as an example of how I try to add the pdf attachment.
Is there something wrong in my code or there is a bug in Email::MIME?
I ran it under Windows XP using ActivePerl 5.14.

use strict;
use warnings;
use Email::MIME;
use Email::Sender::Simple qw(sendmail);
use Email::Sender::Transport::SMTP qw();
use utf8;

open my $in, '<', "bogus-report.pdf";
binmode $in;
my $pdf = do { local $/; <$in> };

my $email = Email::MIME->create(
    header_str => [
        From => 'Oct Râş <me@example.ro>',
        To => 'Me too <me@gmail.com>',
        Subject => 'Subj ţţţ',
    ],
    parts => [
        Email::MIME->create(
            body_str => "Hello there",
            attributes => {
                content_type => "text/plain",
                charset => "US-ASCII",
                encoding => "quoted-printable",
            },
        ),
        Email::MIME->create(
            body => $pdf,
            attributes => {
                content_type => "application/pdf",
                name => "bogus-report.pdf",
                filename => "bogus-report.pdf",
                encoding     => "quoted-printable",
            },
        ),
    ],
);


Thanks

--Octavian


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About