Codice PHP:
<%
'Sample file Form-Email.asp 
Let's you send one an email with one or more attachments.

'
Global declarations.
'Get temporary folder
Dim ResultHTML

'
Create upload form
'Using Huge-ASP file upload
'
Dim FormSet Form Server.CreateObject("ScriptUtils.ASPForm")
'Using Pure-ASP file upload
Dim Form: Set Form = New ASPForm %><% 

'
Do not upload data greater than 1MB
Server.ScriptTimeout 1000
Form
.SizeLimit = &H100000

Const fsCompletted  0

If Form.State fsCompletted Then 'Completted
  ResultHTML = ProcessForm
ElseIf Form.State > 10 then
  Const fsSizeLimit = &HD
  Select case Form.State
        case fsSizeLimit: ResultHTML = "
<Font Color=red>Source form size (" & Form.TotalBytes & "B) exceeds form limit (" & Form.SizeLimit & "B)</Font>
"
        case else ResultHTML = "
<Font Color=red>Some form error.</Font>
"
  end Select
End If 
if request.QueryString("Action") = "Cancel" then
    ResultHTML = "
[b]Upload was cancelled[/b]"
end if

Function TempFolder()
    Dim FS
  Set FS = CreateObject("Scripting.FileSystemObject")
  '
Get temporary folder
  TempFolder 
FS.GetSpecialFolder(2) & "\emailtemp"
End Function

Sub DeleteFile(FileName)
    
Dim FS
  Set FS 
CreateObject("Scripting.FileSystemObject")
    
FS.DeleteFile FileName
End Sub




Function ProcessForm
  Dim eFrom
eToSubjectMessage

  
'get source form fields - From, To, Subject and Message
  eFrom = Form("From")
  eTo = Form("To")
  Subject = Form("Subject")
  Message = Form("Message")
  
  Dim HTML
  HTML = "
<Font Color=red>     Server-side ASP script accepted source form with fields and files and email object was created. "
  HTML = HTML & "

Email parameters:"
  HTML = HTML & "
From: [b]" & eFrom & "[/b]"
  HTML = HTML & "
To: [b]" & eTo & "[/b]"
  HTML = HTML & "
Subject: [b]" & Subject & "[/b]"
  HTML = HTML & "
Message: [b]" & Message & "[/b]"

  Dim objNewMail, File, FileName

  '
Create a new email message
  Set objNewMail 
CreateObject("CDONTS.NewMail")
  Const 
CdoMailFormatMime 0
  objNewMail
.MailFormat CdoMailFormatMime
  
'Save source files to temporary folder
  '
Add these files to the new e-mail
    HTML 
HTML "
Attachments:"
  
For Each File In Form.Files.Items

    
'If source file is specified.
    If Len(File.FileName) > 0 Then

      HTML = HTML & "
" & File.Name & ": [b]" & File.FileName & ", " & File.Length \ 1024 & "kB[/b]"
      FileName = TempFolder & "\" & File.FileName 
    
      File.SaveAs FileName
      
      objNewMail.AttachFile FileName
    End If
  Next
  
  '
Send the new email
  objNewMail
.Send eFromeToSubjectMessage

  
'delete temporary files
  For Each File In Form.Files.Items
    If Len(File.FileName) > 0 Then
      FileName = TempFolder & "\" & File.FileName
      on error resume next
      DeleteFile FileName
    End If
  Next
  HTML = HTML & "</Font>
"
  ProcessForm = HTML
End Function



%>  
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
 <TITLE>ASP huge file upload sample.</TITLE>
 <STYLE TYPE="text/css"></STYLE>
 <meta name="robots" content="noindex,nofollow">
</HEAD>
<BODY BGColor=white>


<Div style=width:600>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  
  <TR>
    <TH noWrap align=left width="20%" bgColor=khaki><A 
      href="http://asp-upload.borec.net">Power ASP 
      file upload with progressbar live sample</A></TH>
    <TD></TD></TR></TABLE>
<TABLE cellSpacing=2 cellPadding=1 width="100%" bgColor=white border=0>
  
  <TR>
    <TD colSpan=2>
      

This sample demontratesusing 
      of Huge-ASP uploadwith asimple email html formand 
      fileattachments. The form contains usual email fields (From, To, 
      Subject, Message) and one form field for file attachement. Number of file 
      fields can be extended using '
Add a file' button (The button uses 
      client-side Javascript and insertAdjacentHTML 
      method).
Server-side ASP script 
      accepts source form fields and files using Huge-ASP upload and 
      thencreates an email using CDONTS.NewMail.</P>
            

This is only short sample, does not contain from/to emails validation or other fields validation.</p>

      Temporary folder for e-mail file attachments is <%=TempFolder%>
  </TD></TR></TABLE>
<%=ResultHTML%>

<TABLE cellSpacing=1 cellPadding=3 bordercolor=silver bgcolor=GAINSBORO width="100%" border=1>
<form method="post" ENCTYPE="multipart/form-data">
  <TBODY>
  <tr><td> From : </td><td><input Name=From Size=50 value="<%=Form("From")%>"></td></tr>

  <tr><td> To : </td><td><input Name=To Size=50 value="<%=Form("To")%>"></td></tr>

  <tr><td> Subject : </td><td><input Name=Subject Size=80  value="<%=Form("Subject")%>"></td></tr>

  <tr><td ColSpan=2> Message:
    
<TEXTAREA name=Message rows=6 cols=76><%=Form("Message")%></TEXTAREA>
  </td></tr>

  <tr><td ColSpan=2>File attachments:
     Form size limit is <%=Form.SizeLimit%>B (<%=Form.SizeLimit \ 1024 %>kB).

    <DIV ID=files>
       Attachment 1 : <input type="file" name="File 1">
    </DIV>
    <INPUT Type=button Value="Add a file" OnClick=return(Expand()) 
     Style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BACKGROUND: yellow; BORDER-LEFT: 0px; CURSOR: hand; BORDER-BOTTOM: 0px">
  </td></tr>

  <tr><td ColSpan=2 Align=right>
    <input Name=SubmitButton Value="Send email &gt;&gt;" Type=submit>
    </td></tr>
  </form></TBODY>
</TABLE>




<SCRIPT>
//Script to add an attachment file field 
var nfiles = 1;
function Expand(){
  nfiles++
  var adh = '
 
Attachment '+nfiles+' : <input type="file" name="File '+nfiles+'">';
  files.insertAdjacentHTML('
BeforeEnd',adh);
  return false;
};

</SCRIPT>