Instructions

These samples are your to use and examine, and only demonstrate a small example of what you can do using ASP Scripts. They also will show how a component works on are server and can be used as a reference. For more information on how to properly create ASP Scripts some links are provided in Links section below.

Database access
Jmail Setup

 

   


Extracting information from an Access Database.

 

Below is an example of the code that connected to the database and extracted the information . Also, on the right side of the table is an explanation of what each line does when the script is ran
As a reminder you must close the connections that you open in your asp script. If you do not properly close you connection after you open them your database will be held open by the server and you will not be able to upload a new one until it is freed. To free a database results in the server being stopped and you site being down until the database can modified.

<%
     Set conn = Server.CreateObject("ADODB.Connection")
        conn.Open " dsn=testserver"
      Set rs=Server.CreateObject("ADODB.Recordset")
        rs.Open "select test from test", conn, 1
%>
<b>
<%
Response.Write rs("test")
%>
</b>
<br>
<!-- Begin Recordset Close -->
<%
           rs.Close
    Set rs = Nothing
%>
<!-- End Recordset Close -->
<!-- Begin Close Data Connection Tag -->
<%
           conn.Close
     Set conn = nothing
%>
<!-- End Close Data Connection Tag -->


Starts the ODBC Connection to a Data Source Name .
States the Data Source Name .
Starts a Record Set Connection to the Database.
Defines the Query, the DSN to use.



Writes the output of the named field. ("field name").





Closes the Record Set Connection.
Sets the rs value to nothing.




Closes the Main Data Access Connection.
Sets the conn value to nothing.

      


Send E-mail with the Jmail Component.

<%
Set JMail = Server.CreateObject("JMail.SMTPMail")

' This is my local SMTP server
JMail.ServerAddress = "mailhub.registeredsite.com"

' This is me....
JMail.Sender = "test@test.com"

E-Mail Subject...
JMail.Subject = "Here you go..."

' Get the recipients mailbox from a form (note the lack of a equal sign).
JMail.AddRecipientex request.form("email"), request.form("name")

' The body property is both read and write.
' If you want to append text to the body you can
' use JMail.Body = JMail.Body & "Hello world!"
' or you can use JMail.AppendText "Hello World!"
' which in many cases is easier to use.
JMail.Body = "Here you go. Your test was sent successfully!"

' 1 - highest priority (Urgent)
' 3 - normal
' 5 - lowest
JMail.Priority = 3

JMail.AddHeader "Originating-IP", Request.ServerVariables("REMOTE_ADDR")

' Must make sure that IUSR_???? has access to the following files.
'JMail.AppendBodyFromFile "e:\mail\standard_footer.txt"


'JMail.AddAttachment "e:\products\MyProduct.exe"


' Send it...
JMail.Execute
%>

<h3>An e-mail has been sent to your mailbox (< %=request.form("email")%>).</h3>


Starts a Connection to the Jmail Object .


Sets the Jmail Object to use this address for the outbound mail server.

This fills in the From; address in the email.


This defines the subject of the email.



This line defines where the email is going to by taking the information from a form. You can set this to go to yourself by changing the line to the following:
JMail.AddRecipient = "you@yourdomain.com"




This line defines the body of the message for the email that you are sending.




This set the priority of the email that is sent.

This line adds the IP address of where this email is coming from and then adds it to the header of the email.



This line is used to add a footer to your email and the user browser must have read permissions on the file for it to be added to the email.

This line defines an attachment that is added to the email when it is sent. This can be used if you are distributing software and what to send it by email after the fill out the form.

This line tells the script to now send the email.


This line can be added to state that the email was sent to the email address listed in the form.

 


Informational Links.

Dimac's Tech Web- Makers of the Jmail component.