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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |