Knowledgebase

KnowledgebaseWeb HostingWindows HostingPlesk Control Panel
Back to Plesk Control Panel

Does Midphase Support CDonts


Cdonts is supported on our Windows hosting plans using classic ASP.

Sending Mail from ASP with CDONTS.NewMail Object

The NewMail object gives you the ability to send a message within an ASP page with only a few lines of code. The syntax for sending mail with the NewMail object of CDONTS is as follows:

objNewMail.Send(  [From]  [, To]  [, Subject]  [, Body]  )

You can create the instance of NewMail Object with the following code.

  <%
Dim objNewMail
Set objNewMail = Server.CreateObject("CDONTS.NewMail")
%>
Properties of NewMail Object.
FromA string value containing the email address of the sender
(for example Me@somewhere.com)
ToA string value containing the email address of the recipient.
(for example, someone@somewhere.com)
Multiple addresses can be added by seperating wih ""
SubjectThe subject line for the message.
BodyA string value containing the body text of the message.
CcA string contains the email addresses of recipients who will receive a copy of the current message.
BccA string containing the email addresses of recipients who will receive a blind copy of the current message.
ImportanceThis is an Integer value that represents the priority of the, message.
(for example High, Normal or Low)
BodyFormatAn integer value which sets the text format of NewMail Object.
ObjMail.BodyFormat = 0 (HTML format)
ObjMail.BodyFormat = 1 (default Plain Text format)
MailFormatAn integer value which sets the encoding of NewMail Object.
ObjMail.MailFormat = 0 (Mime format)
ObjMail.MailFormat = 1 (default Plain Text format)




Methods of NewMail Object.

AttachFileThis method attaches a file to the current message.
AttachURLThis method attaches a file to the current message and associates a URL with that attachment.
SendThis method sends the message.

After the send method, the NewMail object becomes invalid but stays in the memory.
You should set the NewMail Object to nothing and release the memory after the Send method.
After the send method, you will have to create a new instance of NewMail Object if you want to send another message.

Let us see how we can use CDONTS. Newmail Object to send mail from an ASP Page.


<%
Option Explicit

Dim objNewMail

' First, create an instance of NewMail Object
Set objNewMail = Server.CreateObject("CDONTS.NewMail")

' After an instance of NewMail Object has been created.
' If you like you can use this one line of code to send the mail.
' objNewMail.Send From, To, Subject, Message
' or you can give every value separate

objNewMail.From = "webmaster@devasp.com"
objNewMail.To   = "test@devasp.com"

' Please replace the "From" and "To" email addresses with your
' own valid email address. I receive too many emails
' from people who test this sample and keep sending
' emails to test@devasp.com, or they keep the "From" property
' as webmaster@devasp.com and I get the response of
' undeliverable emails.
' NOTE: If the "To" or "From" properties of CDONTS contain
' invalid email address you will not receive the email.

objNewMail.Subject = "This is a test Mail"
objNewMail.Body    = "This is the Body text of this test mail."
objNewMail.Send

' After the Send method, NewMail Object becomes Invalid
' You should set it to nothing to relieve the memory

Set objNewMail = Nothing

' If you want to send another mail
' you have to create a new instance of NewMail Object again.

Response.Write "Email has been sent"

%>




Related Articles

Does Midphase Offer ASP
Does Midphase Offer MSSQL With Any Midphase Hosting Plans
Does Midphase Support ASP.NET 2.0 - 4.0 Or ASP Or Ajax
Does Midphase Support AspUpload And AspImage
Does Midphase Support Microsoft Exchange

Can’t Find what you need?

No worries, Our experts are here to help.