Sending eMail in ASP (CDONTS)
14.12.2005, 13:27
Submited in: Asp | Total Views: 35639
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: form.html
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1250"> <title>Mail example</title> </head> <body> <form action="sendmail.asp" method="post" name="form" id="form"> Your mail:<br> <input name="from" type="text" id="from"> <br><br> Recipient:<br> <input name="to" type="text" id="to"> <br><br> Subject:<br> <input name="subject" type="text" id="subject"> <br><br> Msg:<br> <textarea name="content" cols="50" rows="8" id="content"></textarea> <br> <br> <input type="submit" name="Submit" value="Submit"> </form> <br> <br> </body> </html> sendmail.asp
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1250"> <title>Sending mail</title> </head> <body>
<% '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
.Send
End With
'Close the server object Set Mail = Nothing %>
</body> </html> Download example (1 KB)
|