AspEmail Component Example

ASP.NET Web Hosting on Cloud Spaces Platform

This article will cover the basics on how to use the AspEmail Component with your hosting account's SMTP Authentication. For additional information on features and more examples in ASP and ASP.NET, visit the link below.

AspEmail Manual:
http://www.aspemail.com/manual.html

The below script will demonstrate how to send messages with the AspEmail component using SMTP Authentication.

<%
'This prevents the form from being Cached.
Response.Expires = 0
Response.Expiresabsolute = Now-1

'Create the MailSender Object
Set Mail = Server.CreateObject("Persits.MailSender")

'Specify your SMTP Mail Server
Mail.Host = "mail.yourdomain.com"

'Specify the From Address and Name
Mail.From = "noreply@yourdomain.com"
Mail.FromName = "Name at YourDomain "

'Specify whom will get the message
Mail.AddAddress "toyou@yourdomain.com", "Your Name "

'Specify the Message Subject and Body
Mail.Subject = "Persits AspEmail Test "
Mail.Body = "Your Message Body "

'Specify of the message is plain text or HTML
Mail.IsHTML = False

'Catch All Errors
On Error Resume Next

'Try to send the message
Mail.Send

'If there is an error, print it out, if the message sends ok, show success!
If Err <> 0 Then ' error occurred
    response.write("Message Error: " & Err.Description)
else
    response.write("Your Message has been sent!")
End If

'Close the Message Object to clear it from memory
Set Mail = Nothing
%>


# SendToQueue method - places a message in a message queue to be retrieved and sent out by the EmailAgent NT service.

# AddEmbeddedImage method - specifies an image to be embedded into a message body.

# AppendBodyFromFile method - reads the message body from a file.

# ContentTransferEncoding property - specifies the Content-Transfer-Encoding MIME header for the message body. If you set this property to "quoted-printable" AspEmail will automatically convert the message body to the Quoted-Printable format which enables you to send messages in non-US ASCII alphabets.

# AltBody property - specifies an alternative text version of the message body to support email clients that are not HTML-enabled.

# CharSet property - specifies the charset component of the Content-Type MIME header. Useful when sending messages in non-US ASCII alphabets.

# Username and Password properties - specify user credentials to be used for AUTH LOGIN authentication against the SMTP server.

# SendToNewsgroup - sends a message (article) to a newsgroup using the NNTP protocol.

Add Feedback