Please help. I am trying to attach a file to a genererated email.
Here is the relevant HTML form code: <FORM ... enctype="multipart/form-data"> and <INPUT ... type=File" name="WordDoc">. And I have pasted the relevant CGI code below.
The problems is that the email works fine until the user actually attempts to attach a file. In other words, if the HTML form is filled-out without attaching a file ($WordDoc) then the email is generated and all is well. But if the user, in addition, attaches a file then the CGI script fails.
the CGI code:
open MAIL, "$mailprogram";
print MAIL "To: $recip\n";
print MAIL "From: $from_addr\n";
print MAIL "Subject: $subject\n";
print MAIL "Content-Type: multipart/mixed; boundary=boundarystring\n";
print MAIL "--boundarystring\n";
print MAIL "Content-type: text/html\n";
print MAIL $message;
print MAIL "--boundarystring\n";
print MAIL "Content-Type: application/msword\n";
print MAIL "Content-Transfer-Encoding: base64\n";
print MAIL "Content-Disposition: attachment; filename='TheWordDoc.Doc'";
print MAIL $FORM{$WordDoc};
print MAIL "--boundarystring--";
close MAIL;
Thank you. Peter.