CodeSnip: Simple SMTP Mailing with .NET
page 1 of 1
Published: 31 Aug 2004
Unedited - Community Contributed
Abstract
Need to send mail directly from your site? Learn how to use the SmtpMail class to do just that.
by Damian Manifold
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 18600/ 27

SMTP Mail is a handy thing to have on any web site, whether for orders or just user feedback. .NET provides you with the System.Web.Mail.MailMessage class which has everything you need to send mail.

Here is a small example of the class in action; it sends the source code to a designated email address. As a side note, it uses cookies to limit how often it can be used. This is done to avoid spam.

Source Code
Email.aspx The Simple SMTP mail sample
Email.aspx.vb The code behind for the sample

You will notice that the System.Web.Mail.SmtpMail class is assigned to a variable before it is used. This is not necessary if you are going to be using the SMTP service on your web server, you can directly call the System.Web.Mail.SmtpMail.Send method.

However the ability to nominate an SMTP server is a nice feature, as it aids administration, in that you have only one SMTP server to worry about configuring and securing.

Examples
Email.aspx the mail example in action

Related Articles
ASP.NET:Email Web Page By Steven Smith
Reading and Writing Cookies In ASP.Net By Don Makoviney



User Comments

Title: Mr.   
Name: Marcelo Zanotto
Date: 2005-09-19 1:25:42 PM
Comment:
muito legal

very cool

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2017 ASPAlliance.com  |  Page Processed at 2017-04-27 7:00:08 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search