[ZT] sending mass e-mails using asp.net

xiaoxiao2021-03-06  41

Sending mass e-mails using asp.netby faisal khan.

OverviewThis article is part II of a series of articles on sending emails from ASP.NET. In the part I, we learned how to send simple text / html email messages. What that article did not cover was how to validate user input ie 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.

Why use mass email? 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. To send market information to a list of subscribe.

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 Controlsfollowing IS A List of All Asp.net Validator Controls:

Used for validating input fields which are required . Used for making sure that the information provided is within a specific text or numeric range . Used for comparing a value in one input field with the one in another . Used for matching the input value with a regular expression . Used for custom validation of the user input using a client-side or server-side method Used for displaming a list of error messages (if any) To the user if validation in one or more vioidation control, we miss.in this article, we'll be missing use of Control.

SendEmail.aspxOk, 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.

Now, Copy / Paste Following Code in IT:

<% @ Page language = "vb" autoeventwireup = "false"%>

<% @ Import namespace = "system.web.mail"%>