Sample Code

From Wiki
Jump to: navigation, search

ASP Sample Code

Form to Email samples (Windows server only)
ASP samples
CDOSYS Email Sample (recommended for ASP use - Windows 2003 servers and after
CDONTS Email Sample ASPMail Email Sample
HTML samples Email Sample
( is a modified version of that is commonly used on Unix servers.

Hidden and Visible Counters (NT and Unix)
Visible Counter for ASP pages

Hidden and Visible Counter

XML example - filling a table
XML Sample

ASP.NET 1.1 - code to send email via script
The following code will send an e-mail without authentication using .Net 1.1:

System.Web.Mail.MailMessage msg = new System.Web.Mail.MailMessage();

msg.To = "[email protected]"; /* separate the addresses with semi-colons like the following "[email protected];[email protected];[email protected]" */

msg.From = "[email protected]";

msg.BodyFormat = System.Web.Mail.MailFormat.Text;  /* change to System.Web.Mail.MailFormat.Html to use HTML in the body */

msg.Subject = ".Net 1.1 Test e-mail subject"; msg.Body = ".Net 1.1 Test e-mail body";

System.Web.Mail.SmtpMail.SmtpServer = ""; System.Web.Mail.SmtpMail.Send(msg);

Response.Redirect("success.html");  /*redirects the client to a page letting them know the email was sent successfully */

To send using authentication, add the following before the System.Web.Mail.SmtpMail lines:

msg.Fields[""] =
msg.Fields[""] = 25;
msg.Fields[""] = 2;
msg.Fields[""] = 1;

msg.Fields[""] =
"[email protected]";
msg.Fields[""] = "password";