Signup · Login
Stardeveloper.com  
Home · Tutorials · Forums · ASP.NET Newsletter Application · Web Hosting Plans · Faisal Khan's Blog · Contact
Search Stardeveloper.com
Newsletter
Enter your email address to receive full length articles at Stardeveloper:


Article Categories
.NET  .NET
  ASP (16)
  ASP.NET (43)
  ADO (16)
  ADO.NET (11)
  COM (6)
  Web Services (4)
  C# (1)
  VB.NET (3)
  IIS (2)

J2EE  J2EE
  JSP (15)
  Servlets (9)
  Web Services (1)
  EJB (4)
  JDBC (4)
  E-Commerce (1)
  J2ME (1)
  Products (1)
  Applets (1)
  Patterns (1)

Main Category  Other
  Website Maintenance (3)
Log In
UserName Or Email:

Password:

Auto-Login:

Hosted by Securewebs.com
 
Home : .NET : ASP.NET : Sending Mass Emails using ASP.NET
 
Read full length articles at Stardeveloper using Twitter Follow on Twitter Facebook Facebook fan page Email Get Articles via Email RSS Get Articles via RSS Feed

Sending Mass Emails using ASP.NET

by Faisal Khan.

Overview
This article is part II of a series of articles on sending emails from ASP.NET. In the part I (Sending Emails using ASP.NET ) of this series of articles, we learned how to send simple email messages. We learned how to plain text as well as HTML emails. What that article didn't cover was how to validate user input i.e. what if user enters nothing or enters invalid information in the HTML form input boxes and how to send mass emails to a list of email addresses without the user knowing that the same email has been sent to other users as well.

If you are looking for a production ready, stable, easy to use ASP.NET Newsletter application, then look no further: Faisal Khan (the author of this tutorial) has created a great Newsletter Application for you to download and start using today. It is easy to install, lets your users subscribe using a subscription form, provides a simple administration interface to create and send newsletters, handles the task of sending newsletters in the background using thread queues on the server, and lets users unsubscribe if they wish so.

Why use mass emailing?
Some of the reasons you may want to use mass emailing are:

  • To maintain a newsletter on your web site to keep your web site members informed of any updates or information of interest related to your web site.
  • To send marketing information to a list of subscribers.

How does mass emailing work?
There are lots of techniques of sending mass emails to users. We'll use the first and most basic one known as "Blind Carbon Copying" or simply "BCC". In this technique, the users that receive the email remain unaware ( blind ) of any other users receiving this email. Besides, there can be any number of user emails specified in this field and all of them will receive the email ( should the email gets sent properly ).

The System.Web.Mail.MailMessage class contains a public property known as "BCC". Any emails separated by semicolons ( ';' ) referenced by this field will receive the email. We'll be using this technique in this article.

Why use form validation?
When receiving input from the user through HTML form fields, usually there are certain fields which are *required* and others are optional. For example, In the part I of this article, we asked users to enter information like 'From', 'To', 'MailFormat', 'Subject' and 'Body' in their respective input fields. To successfully complete the transaction we needed all of this information and that ASP.NET script would have failed had you missed any input field.

So how will we validate user input?
We'll make use of built-in ASP.NET validator controls to do all the validation for us. They give us great deal of flexibility in handling input validation, we can specify which fields to be validated, what error message to show if user entered invalid information, the ability to display all the error messages as a list to the user and to proceed if all the information has been validated otherwise wait and display the validation summary to the user.

Brief summary of ASP.NET validator controls
Following is a list of all ASP.NET validator controls:

  1. <asp:RequiredFieldValidator>
    Used for validating input fields which are required.

  2. <asp:RangeValidator>
    Used for making sure that the information provided is within a specific text or numeric range.

  3. <asp:CompareValidator>
    Used for comparing a value in one input field with the one in another.

  4. <asp:RegularExpressionValidator>
    Used for matching the input value with a regular expression.

  5. <asp:CustomValidator>
    Used for custom validation of the user input using a client-side or server-side method.

  6. <asp:ValidationSummary>
    Used for displaying a list of error messages ( if any ) to the user if validation in one or more validation controls failed.

In this article, we'll be making use of <asp:RequiredFieldValidator> control.

SendEmail.aspx
Ok, let's create the new SendEmail.aspx page for part II of this article. Rename the old "SendEmail.aspx" ASP.NET page that you created in part I of this article to some other name ( so that we can create the new and better SendEmail.aspx page for this article ) and create a new "SendEmail.aspx" page in the same folder.


 ( 3 Remaining ) Next

Comments/Questions ( Threads: 9, Comments: 19 )
    Contains 1 or more replies by the Author of this Article.
    Contains 1 or more replies by Faisal Khan.

  1. Displaying error timed out ( 1 Reply )
  2. price of .NET Framework
  3. sending mails ( 1 Reply )
  4. Delete file from Server.... ( 1 Reply )
  5. Something wrong with this line ( 1 Reply )
  6. how can i use this with Access database
  7. Smtp mail in asp.net
  8. smtp-server ( 4 Replies ) This thread contains 1 reply by the Author of this Article. This thread contains 1 reply by Faisal Khan.
  9. why use bcc? ( 2 Replies ) This thread contains 1 reply by the Author of this Article. This thread contains 1 reply by Faisal Khan.

Post Comments/Questions

In order to post questions/comments, you must be logged-in. If you are not a member yet, then signup, otherwise login. Once you login then come back to this page and you'll see a form right here which will allow you to post comments/questions.

Please note, one of the benefits of signing up is to be notified immediately by email everytime you receive a reply to the thread you have subscribed.

 
© 1999 - 2010 Stardeveloper.com, All Rights Reserved.