rajyalakshmi has asked for the wisdom of the Perl Monks concerning the following question:

Hi ALL,

I am using the following script to send mail.My requirement is to send mail with file sent as an inline.But though i have used 'Dispostion' as inline i am still getting the text file as attachment.Kindly let me know how can i send a file as inline not attachement

#!/usr/bin/perl use MIME::Lite; my $msg = MIME::Lite->new( From => 'some1@somewhere', To => 'some1@somewhere', Cc => 'some2@somewhere,some3@somewhere,some4@somewhere,some5@ +somewhere', Type => 'multipart/mixed', Subject => "Fetch issues as on '$dateFile'", Dispostion=>'inline', ); $msg->attach( Type => 'TEXT', Data => "Hi,Please find attachement for Fetch issues seen in c +ategories as on '$dateFile'", ); $msg->attach( Type => 'text', Path => '/var/newshunt/Fetch_script/exceptions_reasons.txt', Filename => 'exceptions_reasons.txt', Dispostion=> 'inline', ); $msg->send;

Replies are listed 'Best First'.
Re: Problem in sending mail with file as inline
by Khen1950fx (Canon) on Sep 25, 2010 at 11:27 UTC
    Note that inline is default. You don't need to list it. Also, the filename shouldn't be exactly like the path. Here, I used "differences.txt". Here's what I came up with:
    #!/usr/bin/perl use strict; use warnings; use MIME::Lite; my $msg = MIME::Lite->new( From => 'some1@somewhere', To => 'some1@somewhere', Cc => 'some2@somewhere,some3@somewhere,some4@somewhere,some5@ +somewhere', Subject => "Fetch issues as on 'dateFile'", Type => 'multipart/mixed', ); $msg->attach( Type => 'TEXT', Data => "Hi,Please find attachement for Fetch issues seen in c +ategories as on 'dateFile'", ); $msg->attach( Type => 'text/plain', Path => '/root/Desktop/exceptions_reasons.txt', Filename => 'differences.txt', ); $msg->send;
Re: Problem in sending mail with file as inline
by zentara (Cardinal) on Sep 25, 2010 at 11:09 UTC
    Hi, try adding the option Path => './mailbody' :
    #!/usr/bin/perl use warnings; use strict; use MIME::Lite; $MIME::Lite::AUTO_CONTENT_TYPE="true"; my $msg = MIME::Lite->new( From => 'zentara' , To => 'zentara@z.net' , Subject => 'test attach', Type => 'multipart/mixed' ); $msg->attach( Path => './mailbody' , Filename => 'message.txt' ); $msg->attach( Path => "./logfile_09-25-2010.tar.gz" , Disposition => "attachment" ); $msg->send; print "Mission accomplished\n";

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh
Re: Problem in sending mail with file as inline
by Anonymous Monk on Sep 25, 2010 at 10:19 UTC
    Type should be a mimetype: text/plain. That may or may not fix your problem, as well.