Select Category
Sitemap Help Contact
print article

Send an E-mail using ASPMail

Follow the steps below to send an e-mail using the ASPMail program.

ASPMail is an Active Server Component designed to send e-mails from an Active Server Page. This component is installed and available on our Web Hosting packages. You can also Send an E-mail Using ASP (CDOSYS)
Send an E-mail Using ASP.NET

Below is a sample ASP script that uses the ASPMail component to send an unauthenticated (no username or password required) test e-mail. To use the sample script:

  • Copy the entire text from within the box below and paste it into a text editor.
  • Edit the top section of the script changing the recipient address to your own e-mail address.
  • Save the text file as sendmail.asp.
  • Upload the file your your webspace.
  • Access the file through your Web Browser using the correct URL.
<%
'-----EDIT THE MAILING DETAILS IN THIS SECTION-----
dim fromName, fromAddress, recipientName, recipientAddress, subject, body, sentTo

fromName = "Test ASP Script"
fromAddress = "address@domain.com"
recipientName = "Your Name Goes Here"
recipientAddress= "yourEmailAddress@yourDomain.com"
subject = "Enter a Subject Title Here!"
body = "Enter the Body of the Mailing Here!"

'-----YOU DO NOT NEED TO EDIT BELOW THIS LINE-----

sentTo = "NOBODY"
Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.FromName = fromName
Mailer.FromAddress = fromAddress
Mailer.RemoteHost = "mrelay.perfora.net"
if Mailer.AddRecipient (recipientName, recipientAddress) then
sentTo=recipientName & " (" & recipientAddress & ")"
end if
Mailer.Subject = subject
Mailer.BodyText = body
if Mailer.SendMail then
Response.Write "The mailing was sent to: <b>" & sentTo & "</b>"
else
Response.Write "Mail send failure. Error was " & Mailer.Response
end if
%>

If you are proficient enough to manipulate the code above, it is also possible to then add additional parameters to the mailing such as attachments, CCs, etc:

Attachments
Mailer.AddAttachment Server.MapPath("somefile.doc")

OR IF IN A SUBFOLDER
Mailer.AddAttachment Server.MapPath("subfolder/somefile.doc")

Carbon Copies (CC)
Mailer.AddCC "Susan Smith", "susan.smith@domain.com"

Blind Carbon Copies (BCC)
Mailer.AddBCC "John Smith", "john.smith@domain.com"

Using a Text File for the Body of an E-mail
Mailer.GetBodyTextFromFile Server.MapPath("welcomeMail.txt"), True,False

OR IF IN A SUBFOLDER
Mailer.GetBodyTextFromFile Server.MapPath("subfolder/welcomeMail.txt"), True,False

For additional information, you may want to reference: