<%@ Language=VBScript %> <%Response.Buffer = True 'enable html buffering so we can use a Redirect anywhere in page '*********************************** IMPORTANT *********************************** ' A folder with the name "4AA80F25-21E4-11D4-9985-0050BAD44BCD" ' will be created at the root of your c:\ drive. If you want to ' delete files uploaded by users then give the default web account ' Full Control permissions for this folder only. Then remove the ' commenting from the "objUpload.Files(j).Delete" line below. '*********************************** IMPORTANT *********************************** '********************************************************************************* 'Copyright Dundas Software Ltd. 2000. All Rights Reserved. ' 'PURPOSE: Processes the information POSTED by SendMail.asp, and then ' attempts to send the email to the specified address(es) along ' with the uploaded attachment (if any). ' 'CONTROLS USED: Dundas Upload and Mailer controls. ' 'COMMENTS: Maximum amount of posted data is 1 Meg. ' Form values are sent back to the main page using a Querystring. ' A maximum of 1 Megabytes of form data is allowed to be uploaded ' to the server (the sum of the posted form data and all uploaded ' files). ' 'Dundas Software Contact Information: ' Email: sales@dundas.com ' Phone: (800) 463-1492 ' (416) 467-5100 ' Fax: (416) 422-4801 '********************************************************************************* Sub DeleteUploads 'removes any files user uploaded from the "c:\4AA80F25-21E4-11D4-9985-0050BAD44BCD" folder Dim j 'counter variable For j = 0 To objUpload.Files.Count - 1 'objUpload.Files(j).Delete Next End Sub %> <% Dim objUpload 'stores Upload control instance Dim strPath 'stores path to the unique folder used to store uploaded files (see notes above) Dim Index 'counter variable Dim objMailer 'stores Mailer control instance 'functions will throw an exception if not successful, so on error resume next is used On Error Resume Next Set objUpload = Server.CreateObject("Dundas.Upload.2") 'Upload object 'if upload object creation failed then redirect to error page with a hyperlink to download page for Uplaod control If Err.Number <> 0 Then Response.Redirect "Error.asp?Error=" & server.URLEncode("You must first install and register the free Dundas Upload Control 2.0 for this demo to work properly.

Click here to download the Upload control.") End If Set objEmail = Server.CreateObject("Dundas.Mailer") 'Mailer object 'create temp directory to store uploaded files if it doesn't already exist ' it is a guid, so it will be a unique folder strPath = "c:\4AA80F25-21E4-11D4-9985-0050BAD44BCD" objUpload.DirectoryCreate strPath 'before saving data we will make sure that the sum of the form data and all uploaded ' files does not exceed 1 Meg. objUpload.MaxUploadSize = 1000000 'save the uploaded files to the temp directory. This populates the Upload control's collections!     objUpload.Save strPath 'error trap for success/failure If Err.Number <> 0 Then Response.Redirect "Error.asp?Error=" & server.URLEncode(Err.Description) End If 'add specified To field to collection, if user did not enter a value redirect to the error page If objUpload.Form("txtTo") <> "" Then objEmail.TOs.Add objUpload.Form("txtTo") Else Response.Redirect ("Error.asp?Error=" & server.URLEncode("You must enter a value for the Recipient field.")) End If 'set FromAddress property objEmail.FromAddress = objUpload.Form("txtFrom") 'set the Subject property objEmail.Subject = objUpload.Form("txtSubject") 'add specified Cc field to collection if specified If objUpload.Form("txtCc") <> "" Then objEmail.CCs.Add objUpload.Form("txtCc") End If 'add specified Bcc field to collection if specified If objUpload.Form("txtBcc") <> "" Then objEmail.BCCs.Add CStr(objUpload.Form("txtBcc")) End If 'check to see if SMTP relay server has been specified, if so add to collection If objUpload.Form("txtSMTP") <> "" Then objEmail.SMTPRelayServers.Add objUpload.Form("txtSMTP") End If 'set the message body objEmail.Body = objUpload.Form("txtBody") 'now add the attachment (if it exists) to the Email control's Attachments collection 'we will also specify the original filename (which doesn't begin with a guid) to be set to the ContentName If objUpload.Files.Count > 0 Then objEmail.Attachments.Add objUpload.Files(0).Path,objUpload.Files(0).OriginalPath End If 'now send the email objEmail.SendMail 'test for success/failure If Err.Number <> 0 Then 'an error occurred so redirect user to the error page Dim ErrString ErrString = Err.Description Call DeleteUploads 'delete the uploaded file (see section at top of page) Set objEmail = Nothing 'release resources Set objUpload = Nothing Response.Redirect "Error.asp?Error=" & server.URLEncode(ErrString) Else 'successful, so redirect back to main page, and set the QueryString "Values" to store form values to be sent back to main page Dim item(5) item(0) = objUpload.Form("txtSMTP") item(1) = objUpload.Form("txtFrom") item(2) = objUpload.Form("txtTo") item(3) = objUpload.Form("txtCc") item(4) = objUpload.Form("txtBcc") item(5) = objUpload.Form("txtSubject") Call DeleteUploads 'delete the uploaded file (see section at top of page) Set objEmail = Nothing 'release resources Set objUpload = Nothing Response.Redirect "SendMail.asp?Success=TRUE&Value1=" & server.URLEncode(item(0)) & "&Value2=" & server.URLEncode(item(1)) & "&Value3=" & server.URLEncode(item(2)) & "&Value4=" & server.URLEncode(item(3)) & "&Value5=" & server.URLEncode(item(4)) & "&Value6=" & server.URLEncode(item(5)) End If %>