$msg = MIME::Lite->new( From    =>"$CompanyName <$CompanyEmail>", To      =>"$CompanyName <$CompanyEmail>", Cc      =>'', Subject =>"Nachricht von $company", Type    =>'multipart/mixed' ); $msg->attach(Type => 'text/html', Data => qq { blah, blah... siehe Anhang. } ); # Verzeichnis öffnen und Inhalt in @files speichern opendir DIR, "$TEMP_DIR/" or &file_error("Unable to open directory. $!"); readdir DIR for 0 .. 1; @files = grep -f "$TEMP_DIR/$_", readdir DIR; closedir DIR; # Datei in @files suchen foreach $_ (@files) { $AttachentFile = (split /\./, $_)[0]; grep /$AttachentFile/i, @files; } # Extension von der gesuchen Datei bestimmen. my $ext = (split /\./, $AttachentFile)[1]; my $MailAttachment = "$TEMP_DIR/$SessionID$ext"; if (!-e $MailAttachment) {&program_error("Keine Datei vorhanden. $!");} # Das sollte den Content-type selbständig bestimmen. $MIME::Lite::AUTO_CONTENT_TYPE = 1; # Attachment anängen, umbennen, Mail abschicken. $msg->attach( Type        =>'auto', Path        =>"$MailAttachment", Filename    =>"picture$ext", Disposition =>'attachment' ); $msg->send;