Dear Gurus, I am using MIME:Lite and a Mail subroutine that I wrote that makes it easy to send out emails with attachments. the code works well for Excel, Word, Pdf and Text files, but it does not work with a file that has an extension .inf but is really a text file. (I was sent the file by another company or I would have ended it in .txt!) I have tried defining a variety of Mimetypes for this file but it just won't email. Can you give me some guidance? Note - The .xnf and .znf extensions referred to below are actually some of the derivations I tried. They were originally put in as .inf.

sub Mail { my($addr,$subj,$body,$attach,$replyaddr,$cclist,$bcclist,$contentt +ype,$onbehalfof) = @_; #Set the name of the sender as it appears in the user's inbox $onbehalfof = $onbehalfof || 'MyCompany <Reports@mycompany.com>'; $replyaddr = $replyaddr || 'Reports@mycompany.com'; #Set the content type (text or html) $contenttype = ($contenttype =~ /^html$/i) ? $MIME_BODYHTML : ($contenttype) ? $contenttype : $MIME_BODYTEXT; #Format cc and bcc lists $cclist =~ s/\;/\,/; $bcclist =~ s/\;/\,/; ### Create a new multipart message: $msg = MIME::Lite->new( From =>"$onbehalfof", To =>"$addr", CC => "$cclist", BCC => "$bcclist", Subject =>"$subj", Type =>'multipart/mixed', 'Reply-To' => "$replyaddr" ); ## Add body text ## $msg->attach( Type =>"$contenttype", Data =>"$body" ); ## Add any attachments ## #Multiple file support @attachfile = split /;/,$attach; while ($attachf = shift (@attachfile)) { if (defined($attachf)){ undef $attachtype; my $attachtype = getmimetype($attachf); # $attachtype = 'application/msword'; print "File ${attachf} is ${attachtype}\n"; $msg->attach( Path => "$attachf", Type => "$attachtype", Disposition => 'attachment' ); } } $smtpserv = $smtpserver; $msg->send('smtp',$smtpserv, Debug=>0); } sub getmimetype { my ($file) = @_; fileparse_set_fstype("MSWin32"); my($name,$path,$extension) = fileparse("$file", '.\w+'); my %MIMETYPES = ( ".doc" => 'application/x-msword', ".dot" => 'application/x-msword', ".wrd" => 'application/x-msword', ".xls" => 'application/vnd.ms-excel', ".xlt" => 'application/vnd.ms-excel', ".pdf" => "application/pdf", ".txt" => "application/txt", ".xnf" => "application/x-setupscript", ".znf" => "application/inf" ); my $mimetype = $MIMETYPES{$extension}; $mimetype = $mimetype || 'text/plain'; return $mimetype; }

In reply to Can't Send a File of Unknown Mimetype by mancusor

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.