Howdy, Stranger!

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


Attaching a file to email

zenozeno Member Posts: 2
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.


  • zenozeno Member Posts: 2
    In addition: Can I do this without using any additional libraries, like LITE?
  • Justin BibJustin Bib USAMember Posts: 0

    _______ < /> free ebooks and video tutorials about ( C Visual Basic .NET R Python MATLAB C++ Ruby Assembly PL/SQL Delphi Objective-C Java PHP Go Scratch Visual Basic Swift C# JavaScript Perl SAS Rust Ada Dart Lua Fortran Prolog F# Logo Scala Alice Bash FoxPro Apex Lisp ML LabVIEW VBScript Julia D COBOL Erlang ABAP Awk Clojure Scheme Kotlin Hack Crystal Transact-SQL ) ____________

Sign In or Register to comment.