%
'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 Form: Set Form = Server.CreateObject("ScriptUtils.ASPForm")
'Using Pure-ASP file upload
Dim Form: Set Form = New ASPForm %><%
'Server.ScriptTimeout = 1000
'Do not upload data greater than 10MB.
Form.SizeLimit = &HA00000
'Progress bar window will receive the same ID.
Form.UploadID = Request.QueryString("UploadID")'{/b}
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 = " Source form size (" & Form.TotalBytes & "B) exceeds form limit (" & Form.SizeLimit & "B) "
case else ResultHTML = " Some form error. "
end Select
End If
if request.QueryString("Action") = "Cancel" then
ResultHTML = " Upload was cancelled"
end if
Function TempFolder()
Dim FS
Set FS = CreateObject("Scripting.FileSystemObject")
'Get temporary folder
'TempFolder = FS.GetSpecialFolder(2) & "\emailtemp"
TempFolder = FS.GetSpecialFolder(2)
End Function
Sub DeleteFile(FileName)
Dim FS
Set FS = CreateObject("Scripting.FileSystemObject")
FS.DeleteFile FileName
End Sub
Function ProcessForm
Dim eFrom, eTo, Subject, Message,lastname,firstname,company,companyaddr,designation,city,state1,zip,countrycode,office,fax,comments,body
lastname=Form("lastname")
firstname=Form("firstname")
company=Form("company")
companyaddr=Form("companyaddr")
designation=Form("designation")
city=Form("city")
state1=Form("state")
zip=Form("zip")
countrycode=Form("countrycode")
office=Form("office")
fax=Form("fax")
comments=Form("comments")
body=""
body="Last name: " & lastname & chr(13) & chr(10)
body= body & "Firstname: "& firstname & chr(13) & chr(10)
body= body & "Company: " & company & chr(13) & chr(10)
body= body & "Company Address: " & companyaddr & chr(13) & chr(10)
body= body & "Designation: " & designation & chr(13) & chr(10)
body= body & "City/Town: " & city & chr(13) & chr(10)
body= body & "State/Province: " & state1 & chr(13) & chr(10)
body= body & "Zip Code: " & zip & chr(13) & chr(10)
body= body & "Country Code: " & countrycode & chr(13) & chr(10)
body= body & "Office: " & office & chr(13) & chr(10)
body= body & "Fax: " & fax & chr(13) & chr(10)
body= body & "Comments: " & comments & chr(13) & chr(10)
'get source form fields - From, To, Subject and Message
eFrom = Form("email")
eTo = "info@regalcad.com"
Subject = "Response from www.regal-services.com"
Message = body
Dim HTML
HTML = " Server-side ASP script accepted source form with fields and files and email object was created. "
HTML = HTML & " From: " & eFrom & ""
HTML = HTML & " To: " & eTo & ""
HTML = HTML & " Subject: " & Subject & ""
HTML = HTML & " Message: " & Message & ""
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 & ": " & File.FileName & ", " & File.Length \ 1024 & "kB"
FileName = TempFolder & "\" & File.FileName
File.SaveAs FileName
objNewMail.AttachFile FileName
End If
Next
'Send the new email
objNewMail.Send eFrom, eTo, Subject, Message
'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 & " "
ProcessForm = HTML
response.redirect ("thankyou.asp?fnam=" & firstname)
End Function
'{b}get an unique upload ID for this upload script and progress bar.
Dim UploadID, PostURL
UploadID = Form.NewUploadID
'Send this ID as a UploadID QueryString parameter to this script.
PostURL = Request.ServerVariables("SCRIPT_NAME") & "?UploadID=" & UploadID'{/b}
%>
Cad Conversion : CAD conversion and CAD drafting services , low cost yet value added services