Sample Code for Components

Article No. 77
Created: 01:48 AM 04.16.04
Author: Support
Original URL: http://myonlinehostingsupport.com/question.php?qstId=77


Please refer to the following code examples when using these components:

ASPMail

<%
Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.FromName = Request.Form("yourname")
Mailer.FromAddress = Request.Form("youraddress")
Mailer.RemoteHost = "mail.domain_name.com"
Mailer.AddRecipient Request.Form("toname"), Request.Form("toaddress")
Mailer.AddCC Request.Form("ccname"), Request.Form("ccaddress")
Mailer.Subject = Request.Form("subject")
message = "Message: " & Request.Form("message")
message = message & vbCRLF
Mailer.BodyText = message
if Mailer.SendMail then
%>

ASPUpload

<%
'Authorize User
' Uplolad Script
Dim members_path
path = Server.MapPath("/")
Set Upload = Server.CreateObject("Persits.Upload.1")
Upload.Save path
For Each File in Upload.Files
   If File.ImageType <> "GIF" and File.ImageType <> "JPG" Then
      Response.Write "GIF or JPG files only please!<BR>"
   End If
   If File.ImageWidth > 150 OR File.ImageHeight > 150 Then
      Response.Write "Image cannot exceed 150 pixels squared.<BR>"
   End IF
   If File.Size > 500000 then
      Response.Write("Too Much!<BR>")
   End If
   Response.Write File.Path & " (" & File.Size &")<BR>"
Next
%>

CDONTS

If you send email using CDONTS, it does not allow you to determine if the email was sent correctly or even if the email address exists. We highly recommend using JMail or ASPMail instead. Both of these components wait until the mail has been delivered before returning control to the ASP page, and they provide error handling for failures.

Set objMail=Server.createobject("CDONTS.NewMail")
objMail.From=strEmail
objMail.To="username@domain.com"
objMail.Subject=strSubject
objMail.Body=strDetails & vbcrlf & vbcrlf & strCompany & vbcrlf & strFirstName & " " & strLastName
objMail.send

SA FileUp

<% Set upl = Server.CreateObject("SoftArtisans.FileUp")
upl.Path = Server.Mappath ("/directory_name")
upl.SaveAs "upload.tst"%>

Back to original article