Sending Mass Emails Part 2

If you haven’t read Part 1 in this series, you can do so now, by clicking here:

Sending Multiple Emails At Once

One of the major drawbacks of creating a mass emailing like we did in Part 1, was personalization and customization were practically non-existent. All email addresses were kept in a string, which populated the BCC section. Each recipient could easily see that this was a mass email. Naturally, that’s normally OK, but by being able to personalize an email gives the recipient a better feeling when he things that the ‘Sender’ of the email took the time to send the email to him, personally. By building your mass email this way, practically any level of personalization and customization is all up to you. For instance, you could create a link in the email itself, that, when clicked, can run a script on your web site to delete that user from the email list automatically.

For this example, all you’ll really need is:

  1. Import the System.Web.Mail namespace
  2. Import the Database namespaces necessary
  3. A table of Data, in the Database (for this sample, we only have two fields (Name and Email)
  4. One subroutine for the code (for this example, we’ll use Page_Load)
  5. A label with an ID of ‘lblEmails’ (only to show the list of emails for the test)

First, we’ll Import the namespaces. For emailing, we must add:

<%@ Import Namespace="System.Web.Mail" %>

For the database (we’re using SQL Server for this tutorial), we must add:

<%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.SQLClient" %>

Now, for the real ‘meat’ of this tutorial, first, we’ll add two Global variables:

Dim sEmail as String Dim sBody as String

Next, in a Subroutine of your choice, add this code:
Continues…

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>