Attaching a file to email - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Attaching a file to email

zenozeno Posts: 2Member
Please help. I am trying to attach a file to a genererated email.

Here is the relevant HTML form code: and . 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
";
print MAIL "From: $from_addr
";
print MAIL "Subject: $subject
";

print MAIL "Content-Type: multipart/mixed; boundary=boundarystring
";

print MAIL "--boundarystring
";
print MAIL "Content-type: text/html
";
print MAIL $message;

print MAIL "--boundarystring
";
print MAIL "Content-Type: application/msword
";
print MAIL "Content-Transfer-Encoding: base64
";
print MAIL "Content-Disposition: attachment; filename='TheWordDoc.Doc'";
print MAIL $FORM{$WordDoc};

print MAIL "--boundarystring--";

close MAIL;

Thank you. Peter.


Comments

Sign In or Register to comment.