Thread Datei mit unbekannter Extension suchen...: ...und mit MIME:Lite verschicken
(18 answers)
Opened by cbxk1xg at 2004-06-06 23:07
[quote=coax,07.06.2004, 14:28]In deinen Code koennte das dann so aussehen:
Code: (dl
)
1 my %hash; Ich werd bekloppt, genau das war die Lösung. Jetzt verstehe ich auch den Teil mit $hash{$SessionID};. Das mit dem Error 500 hat sich nun auch auf wundersame Weise gelöst. Vielen Dank an alle!!! Für die, die es interessiert, hier die Lösung im Ganzen: Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 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; my %hash; foreach my $filename (@files) { my($base) = $filename =~ /(.+?)\..+?$/; $hash{$base} = $filename; } my $MailAttachment = "$TEMP_DIR/" . $hash{$SessionID}; my $ext = (split /\./, $MailAttachment)[-1]; my $picturename = "bild"; if (!-e $MailAttachment) {&program_error("Keine Datei vorhanden. $!");} use MIME::Lite; # Create a new multipart message: $msg = MIME::Lite->new( From =>"$CompanyName <$CompanyEmail>", To =>"$CompanyName <$CompanyEmail>", Cc =>'', Subject =>"Nachricht von $company", Type =>'multipart/mixed' ); # Add parts (each "attach" has same arguments as "new"): $msg->attach(Type => 'text/html', Data => qq { bla, bla } ); # Add the attachment and automaticly determine the content type: $MIME::Lite::AUTO_CONTENT_TYPE = 1; $msg->attach( Type =>'auto', Path =>"$MailAttachment", Filename =>"$picturename.$ext", Disposition =>'attachment' ); $msg->send; Ich bin mir zwar immer noch nicht sicher ob der Teil: so 100%ig stimmt, aber auch mit PDFs und JPEGs scheint es da nach meinem Test, kein Problem zu geben. Noch mals, vielen Dank! |