You can't create a new empty object and add data to it.

Sure you can

#!/usr/bin/perl -- use strict; use warnings; use MIME::Lite; my $msg = MIME::Lite->new; ## no data $msg->build( qw/ to you from me Data Data1 /); ## data $msg->build( qw/ subject SUBJECT /)->data('Data2'); ## data $msg->attach( qw/ Data DATA3 /); ## data $msg->print; __END__ Content-Transfer-Encoding: 7bit Content-Type: multipart/mixed; boundary="_----------=_150136405630120" MIME-Version: 1.0 Date: Sat, 29 Jul 2017 14:34:16 -0700 To: you From: me Date: Sat, 29 Jul 2017 14:34:16 -0700 Subject: SUBJECT X-Mailer: MIME::Lite 3.029 (F2.84; T2.04; A2.12; B3.14; Q3.13) This is a multi-part message in MIME format. --_----------=_150136405630120 Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain Data2 --_----------=_150136405630120 Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain DATA3 --_----------=_150136405630120--

In reply to Re^5: Error in MIME::Lite? by Anonymous Monk
in thread Error in MIME::Lite? by littlelion

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.