Hosting Support Language
 
Information
Article ID9
Created On11/30/2008
Modified11/30/2008
How to: Send email with ASPEmail

AspEmail is an active server component for sending email messages using an external SMTP server in an ASP or VB environment.

Simple Text Email:

<%

Set Mail = Server.CreateObject("Persits.MailSender")

Mail.Host = "smtp.mycompany.com"
'or Mail.Host = "smtp.mycompany.com;smtp2.mycompany.com;host.someothercompany.com" 

Mail.Port = 25 ' Optional. Port is 25 by default

Mail.From = "sales@mycompany.com"
Mail.FromName = "Sales Department" ' Optional

Mail.AddAddress "jsmith@company1.com", "John Smith"

Mail.Subject = "Sales Receipt"
Mail.Body = "Dear John:" & chr(13) & chr(10) & "Thank you for your business. Here is your receipt."

On Error Resume Next
Mail.Send
If Err <> 0 Then
    Response.Write "An error occurred: " & Err.Description
End If

%>

Send Mail to CC and Bcc:

<%

Set Mail = Server.CreateObject("Persits.MailSender")

Mail.Host = "smtp.mycompany.com"
'or Mail.Host = "smtp.mycompany.com;smtp2.mycompany.com;host.someothercompany.com" 

Mail.Port = 25 ' Optional. Port is 25 by default

Mail.From = "sales@mycompany.com"
Mail.FromName = "Sales Department" ' Optional

Mail.AddAddress "jsmith@company1.com", "John Smith"
Mail.AddCC "bjohnson@company2.com" ' Name is optional
Mail.AddBcc "anotherperson@company3.com"

Mail.Subject = "Sales Receipt"
Mail.Body = "Dear John:" & chr(13) & chr(10) & "Thank you for your business. Here is your receipt."

On Error Resume Next
Mail.Send
If Err <> 0 Then
    Response.Write "An error occurred: " & Err.Description
End If

%>

Sending Email in HTML Format:

<%

Set Mail = Server.CreateObject("Persits.MailSender")

Mail.Host = "smtp.mycompany.com"
'or Mail.Host = "smtp.mycompany.com;smtp2.mycompany.com;host.someothercompany.com" 

Mail.Port = 25 ' Optional. Port is 25 by default

Mail.From = "sales@mycompany.com"
Mail.FromName = "Sales Department" ' Optional

Mail.AddAddress "jsmith@company1.com", "John Smith"

Mail.Subject = "Sales Receipt"
Mail.Body = "<HTML><BODY BGCOLOR=#0000FF>Dear John:....</BODY></HTML>"
Mail.IsHTML = True

On Error Resume Next
Mail.Send
If Err <> 0 Then
    Response.Write "An error occurred: " & Err.Description
End If

%>

Sending Attachment:

<%

Set Mail = Server.CreateObject("Persits.MailSender")

Mail.Host = "smtp.mycompany.com"
'or Mail.Host = "smtp.mycompany.com;smtp2.mycompany.com;host.someothercompany.com" 

Mail.Port = 25 ' Optional. Port is 25 by default

Mail.From = "sales@mycompany.com"
Mail.FromName = "Sales Department" ' Optional

Mail.AddAddress "jsmith@company1.com", "John Smith"

Mail.Subject = "Sales Receipt"
Mail.Body = "Dear John:" & chr(13) & chr(10) & "Thank you for your business. Here is your receipt."

Mail.AddAttachment "c:\dir\receipt.doc"

On Error Resume Next
Mail.Send
If Err <> 0 Then
    Response.Write "An error occurred: " & Err.Description
End If

%>