Sending eMail in ASP (CDONTS)

14.12.2005, 13:27
Submited in: Asp | Total Views: 38730

In this tutorial I'll show how to send mail with CDO (Collaboration Data Objects).

Hereís a simple form and itís associated ASP page to send the email:

<meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
<title>Mail example</title>
<form action="sendmail.asp" method="post" name="form" id="form">
  Your mail:<br>
  <input name="from" type="text" id="from">
  <input name="to" type="text" id="to">
  <input name="subject" type="text" id="subject">
  <textarea name="content" cols="50" rows="8" id="content"></textarea>
  <input type="submit" name="Submit" value="Submit">


<meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
<title>Sending mail</title>

'Dimension variables
Dim Mail
Dim MailFrom
Dim MailTo
Dim MailSubject
Dim MailContent

MailFrom = Request.Form("from")
MailTo = Request.Form("to")
MailSubject = Request.Form("subject")
MailContent = Request.Form("content")

'E-mail server object
Set Mail = Server.CreateObject("CDONTS.NewMail")

With Mail

'Who the e-mail is from
.From = MailFrom

'Who the e-mail is sent to
.To = MailTo

'Subject of the mail
.Subject = MailSubject

'Mail body format 0=html 1=text
.BodyFormat = 0

'Mail format (0=MIME 1=Text)
.MailFormat = 0

'Content of the email
.Body = MailContent

'Importance (0=Low 1=Normal 2=High)
.Importance = 1


End With

'Close the server object
Set Mail = Nothing


Download example (1 KB)

Are you a website owner?
Click here to register and submit your tutorials!

Browse by category

Most popular tutorials

Resources Worth visiting