MailIt Function:

The MailIt function sends an email message to a recipient. MailIt returns True if the mail is sent successfully and False if the mail is not sent for any reason. MailIt supports sending email via two COM objects available on most servers. There are five required arguments: classstring, mailto, mailfrom, mailsubject, and mailbody.

Argument Expects
ClassString Acceptable values are "jmail.smtpmail" or "cdonts.newmail"
MailTo Valid EMail address as string
MailFrom Valid Email address as string
MailSubject Subject text as string
MailBody Body text as string


Syntax:
boolean = MailIt(classstring, mailto, mailfrom, mailsubject, mailbody)
Example Usage:
Use MailIt to send an email with the jmail.smtpmail object.
<%
Const UseJmail = "jmail.smtpmail"
Dim boolSent

boolSent = MailIt(UseJmail, "to@to.com", _
		"from@from.com", "mail subject line", "mail body text")
If boolSent Then
	Response.Write "Mail Sent Successfully!"
Else
	Response.Write "Mail Not Sent!"
End If
%>
Use MailIt to send an email with the CDONTS.NewMail object.
<%
Const UseCDO   = "cdonts.newmail"
Dim boolSent

boolSent = MailIt(UseCDO, "to@to.com", _
		"from@from.com", "mail subject line", "mail body text")
If boolSent Then
	Response.Write "Mail Sent Successfully!"
Else
	Response.Write "Mail Not Sent!"
End If
%>
ASP Source Code:
<%
Private Function MailIt(byVal classstring, byVal mailto, _
    byVal mailfrom, byVal mailsubject, byVal mailbody)
	Dim Mailer, objCDO
	Select Case LCase(classstring)
		Case "jmail.smtpmail"
			On Error Resume Next
			Set Mailer = Server.CreateObject("jmail.smtpmail")
			With Mailer
				.ServerAddress = "entermailserveraddresshere"
				.Sender = mailfrom
				.AddRecipient mailto
				.Subject = mailsubject
				.Body = mailbody
				.Execute
			End With
			If Err Then 
				MailIt = False
			Else 
				MailIt = True
			End If
			Set Mailer = Nothing
			On Error GoTo 0
		Case "cdonts.newmail"
			On Error Resume Next
			Set objCDO = Server.CreateObject("CDONTS.NewMail")
			With objCDO
				.Subject = mailsubject
				.To = mailto
				.From = mailfrom
				.Body = mailbody
				.Send
			End With
			If Err Then 
				MailIt = False
			Else 
				MailIt = True
			End If
			Set objCDO = Nothing
			On Error GoTo 0
		Case Else
			MailIt = False
			Err.Raise 5030, "MailIt Function", _
				"Unknown class string argument. " & _
				"The MailIt function does " & _
				"not support this mail object."
	End Select
End Function
%>