jump to navigation

User front end for mlists November 9, 2006

Posted by _netoLopez in .net, c#, mlists, programming, projects, web2.0.
add a comment

Ok, now to implement our MailingList class on an application…

I’ll start by showing a screenshot of my outcome,

MailingList GUI

notice I divided it by coloring some sections as follows:
- Orange, active mlists
- Yellow, selected mlist detail
- Blue, create a new mlist
- Green, subscribe/unsubscribe to an mlist
- Gray, distribute some “html” content to a list

The Orange section

Here, we interact with the MailingList class by means of the GetActiveLists() static method, to get a string array of active mlists on the database. With the string array, I iterate thru it and output some more ways to interact with a MailingList object to accomplish other stuff (refer to the links).  Since I already have the active mlist codes, I also use the same iteration to populate some dropdowns on the Green and Gray sections, which we’ll see later.


Other things that can be covered for the Orange section are the view link and the expire link.

View link: this will show us the active (not expired) email addresses that are subscribed to the mlist. On my implementation, this will popup a new window.


This popup contains the mlist Name in bold, followed by the mlist Description, and then the list of subscribers.

This is my implementation of the View view :P


the mlist object is instantiated relying on a QueryString parameter provided by the document opener (as I used a popup). This is the url I used to load the window:
http://server/MailingLists/mlist_entries.aspx?c=Presentation. This will render the Presentation mlist detail to screen!

Expire link: clicking here, will remove the mlist from the list. I accomplished this by going to another page, doing the thing, and then coming back to the initiating page. Here’s the code:


Again, the mlist is instantiated relying on a QueryString parameter coming from the referer link (?c=mlist.Code).

When the flow goes back to the referer page, it will execute the Page_Load() method, which will ask the MailingList class for the active lists, the recently expired mlist will no longer be included…

The Yellow section

There’s also another user event that goes on on the Orange section, this is when the user clicks on the mlist code. Clicking on the mlist code from the Orange section, will make the Yellow section display the selected mlist detail.

I will not go into detail on my implementation, I’ll just state an overview of what I did.

Used Ajax to tell the server to make an html table with the Name and Description of a specific mlist. Put the resulting html table into the Yellow section (I may expand on the topic on a later blog entry).

The Blue section

This section will use the MailingList class to create more mlists. This is done by means of the Create() static method. The method argument values are provided on the textboxes.


I used the Response.Redirect() to deal with the repainting of the mlist list on the Orange section.

The Green section

The subscription and removal of email addresses from certain mlist will be handled with the Green section. The user would type an email address and select the desired mlist he/she wishes to affect.


The Gray section

The last section we’ll cover is the Gray one, where you get to send the same email to all the entries in an mlist. You select the target mlist from the dropdown, and type in a subject and some content, then hit the Publish button :mrgreen:


… I think this wraps up the Mailing List application series (mlists), please post your comments and thoughts about the series and any suggestions for future ones…

The Logical Layer (mlists) November 6, 2006

Posted by _netoLopez in .net, c#, database, mlists, mssql, programming, projects, web2.0.
add a comment

…or business logic tier, or middle tier/layer…, what I mean to say is that the code on the MailingList class that I’ll present is not tied to any GUI/display functions, meaning it may be used in a web environment, or a desktop application just fine.

Let’s start by viewing and explaining the required .net namespaces:

MailingList namespaces

The System namespace is always used.
The System.Data will supply us with generic data objects like DataTable and DataRow.
System.Configuration we use because we rely on a configuration file (same for web or desktop) to store certain values like connectionStrings.
System.Data.SqlClient is used to connect to an SqlServer2oo5 database instance (or file in our case because of express edition).
And last but not least, the System.Net.Mail namespace we use to send email messages thru SMTP (this is new in .net 2.0 as previously we had to use System.Web.Mail).

This is how I implemented the properties, all of them are read-only…

MailingList properties

I have specified a public constructor that accepts a code parameter to initialize the object properties based on it, and hidden the default constructor from public use; making it private thou, I can still use it on my static methods shown later.

MailingList Constructors

Basically, the public constructor will use the supplied code to get the rest of the property values (name and description). Recall the table definitions on previous post. Notice the use of the helper database method GetDataTable().

Static methods (no instantiation needed)
I implemented two static methods that do not require MailingList to be instantiated to be used.  These are Create() and GetActiveLists().

Create() is used to “add” a new list to the application.  GetActiveLists() will return an array of list codes.

MailingList static methods

Create() method: there are some validations pending, but left them as TODOs to keep the code sample short.  I did do validation to check if the code already exists, and threw an ApplicationException if it in fact exists… Else if the provided code is valid, a new list is created!

GetActiveLists() method: This will query the database and get the list codes that have not been expired.

Object Methods

MailingList expire

When called, Expire() will remove the list from active lists, setting a datetime value on the [expires] field.

MailingList subscribe

The Subscribe() method, will add an email address to the currently instantiated mailingList. Notice it is first activating the email address by “unexpiring” it (putting null on [expires]);  and if this doesn’t work (variable i will be zero), it’ll insert a new row.  I did this because on the mlists_entries table, I placed a uniqueness constraint on the [list_id]+[inbox] columns.

MailingList unsubscribe

This one will do the opposite, it’ll remove an email address from the active list of addresses in the current list.

MailingList update

the Update() method is our way to edit the name and description properties of our mailingList instance.

MailingList getEntries

GetEntries() will retrieve an array of active email addresses from the current mailingList object.

MailingList publish

And the Publish() method, will send an email message to each of the emails retrieved by the GetEntries() method.  This method got a little messy… First, I’m getting some values from the web.config file, being senderInboxDomain and smtpServer.  The senderInbox variable, used to set the From property of the MailMessage instance, is composed of the code ([list_id]) of the mailingList plus the senderInboxDomain.  Second, I am appending stuff to the htmlContent (used as the main body of the MailMessage instance), I recommend appending the following two things to a mailingList message: a disclaimer & a way for the recipient to remove themselves from the list.  Third, the method is relying on the GetEntries() method to get the list of email addresses, and then looping thru them sending the message to each one :D .

Wrapping up the MailingList class
This is all the code I placed on the MailingList class. It covers all the requirements listed in the first post of this series (mlists).  My next entry will touch some activities I did when implementing the user interface portion of the project.

Creating mailing list application, the beginning November 1, 2006

Posted by _netoLopez in design, mlists, programming, projects, web2.0.
1 comment so far

Hello, for my first real post here, I’ll attempt to step thru the design, development, and possibly the implementation of a simple, extendable application to manage mailing/distribution lists (this accomplished by a series of posts =D).

(this is my first post and getting familiarized with linking and inserting images :P)

A mailing list, as I grasp the concept, would be a list of emails that grows as interested people subscribe to the list because they want to receive periodic updates on a certain topic.  They can also unsuscribe when they choose to of course.

The series of posts relating the mailingList component, will try to adhere to the following toc:

  • requirements
  • backend design
  • class(es) design
  • choosing the technology set
  • showing some code
  • maybe implementing somewhere, or choices

Requirements – Starting from the beginning

I’ll list some basic requirements that should be present in the solution:

  • manage lists
    • add
    • delete
    • edit
  • subscribe
  • unsubscribe
  • distribute

That looks like a simple, yet functional set of requirements for our project…  This one other comes to my mind, but I’ll exclude it to keep simplicity [html or plain text format as preference].

The Backend design (as in where to store the data)

{this rich text control on wordpress is really cool! easy to use!!}

This is how I envision the dataStore entities, I may change my mind as we go ahead :P

  • mlists
    • list_id : string [PK]
    • list_name : string
    • list_desc : string
    • expires : date
  •  mlists_entries
    • entry_id : number [PK]
    • list_id : string
    • inbox : string
    • expires : date

description of mlists: in this table, we would manage the list set.  Here’s where we would add new lists, edit them if necessary, and “remove” them.  There are some scenarios where deleting does not necessarily means DELETE, but hide… that’s what the [expires] field will do, if the date stored here is smaller than “current_date”, that means it is inactive. 

description of mlists_entries: here, we will keep track of the emails that are subscribed to a certain list from [mlists].  [expires] serves the same function as in [mlists].

my time’s up, but I’ll continue in a bit :D


Get every new post delivered to your Inbox.