Click here to Skip to main content
Click here to Skip to main content

YaMessaging - A simple e-mail like messaging application

By , 19 Apr 2012
 

Introduction

This article contains a small email application which is developed using ASP.NET, C#, and ADO.NET.

Background

Last week someone asked a question in "The Code Project - Quick Answers" section on how to develop an email application. When I asked him about what he needed, he said he needed an email application that will only work inside an organization and there is no need to send/receive emails to other email providers. It was more of a messaging system where users can use their credentials to log into the site and can send/receive messages from other users of the site.

This made me realize that one of my previous employers also wanted such an application just for internal communication within the organization. Since we didn't have anyone to write one, we ended up using GMail for this.

The idea behind this small project that I made in couple of hours is to provide a skeleton for such an application. There might be some small businesses wanting such an application and they will perhaps be able to use this application with some changes.

This application is a very simple application sending messages to other registered users of the site. The database design is very simple and not optimized. There is no design on presentation layer (I am pretty bad at that). And to some people, the functionality might also seems simple like in a student project. The good thing about this application is that it follows proper n-tier architecture. Also it uses ADO.NET and I agree an ORM could have been used to do this but I like the power and control that ADO.NET provides and so I used it instead.

Using the Code

Let's start by talking about the architecture of this application. This application is designed using an n-tier architecture. I have a Data Layer that provides database related functionalities. On top of the data layer, I have my Data Access Layer (DAL) which has all the data access functionalities (using ADO.NET). On top of DAL, I have a Business Logic Layer (BLL) which contains the application specific functionality. And finally on top of the BLL, my presentation layer is developed using ASP.NET web forms. All these layers are in separate solutions so that changing a layer will have minimal or no impact on other layers. To visualize my application architecture:

The Data Layer

The Data Layer mainly contains the database schema and the Stored Procedures to use the database. I tried to put most of the database interactions as Stored Procedures. I always prefer having Stored Procedures. If I can't achieve something using Stored Procedures, I use parameterized commands. I never ever user string concatenated SQL statements from code as this approach is error prone and makes the application vulnerable to SQL Injection attacks. Let's now look at the database tables in the application.

The Stored Procedures created in the application are:

The Data Access Layer

The data access layer talks to the database, retrieves the results, and passes it to the business logic layer in the form of DataSets and/or DataTables. The DAL contains the following classes:

The Business Logic Layer

The BLL takes care of manipulating data as per the request from the user interface, and has some checks and operations that need to be performed. The main classes in our BLL are:

The Presentation Layer

The presentation layer is a set of ASP.NET web pages that provides the pages for "inbox view", "sent view", etc., to the user. The application currently has an administrator who can add new users and the added users can send messages to any other user. The users can also change their passwords. I have only put bare minimum validations in the presentation layer. I am using some client side and some server side checks to perform validations. The user management is being done by the application, i.e., ASP.NET Roles and Membership is not being used (this is because someone might want to use this application and his server might not support these features properly).

Following are screenshots of a few functionalities of the application.

The Inbox View

The Compose View

The Sent Messages View

How to Run the App

A few user IDs that I created for testing can be used to play around with the application.

  • userid: one, password: one
  • userid: two, password: two
  • userid: three, password: one
  • userid: Rajat, password: 12345

Also the Admin login for the application is:

  • userid: admin, password: 12345

Points of Interest

This application has been developed in around 3 hours time so it might contain some bugs. The idea behind this application was as yet another attempt in explaining the n-tier architecture. I am really looking forward for some feedback and would really appreciate suggestions and constructive criticisms.

Planned Future Work

  • Having the admin/users provide their SMTP server details and credentials so that their messages can be pushed to their email IDs.
  • Have a nice frontend interface instead of this boring white, perhaps will try to incorporate jQuery UI for this.

History

  • 20 April 2012: [Bug Fix]Validation error while adding recipients.
  • 22 March 2012: First version.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Rahul Rajat Singh
Software Developer (Senior)
India India
Member
I Started my Programming career with C++. Later got a chance to develop Windows Form applications using C#. Currently using C#, ASP.NET & ASP.NET MVC to create Information Systems, e-commerce/e-governance Portals and Data driven websites.

My interests involves Programming, Website development and Learning/Teaching subjects related to Computer Science/Information Systems.
 
Some CodeProject Achievements:
  • 9th in Best Web Dev article of March 2013
  • 7th in Best Web Dev article of January 2013
  • 2nd in Best C# article of December 2012
  • 5th in Best overall article of December 2012
  • 5th in Best C# article of October 2012
  • 4th in Best Web Dev article of September 2012
  • 3rd in Best C# article of August 2012
  • 5th in Best Web Dev article of August 2012
  • 5th in Best Web Dev article of July 2012
  • 3rd in Best Overall article of June 2012
  • 2nd in Best Web Dev article of June 2012
  • 5th in Best Web Dev article of May 2012
  • 6th in Best Web Dev article of April 2012
  • 4th in Best C++ article of April 2012
  • 5th in Best C++ article of March 2012
  • 7th in Best Web Dev article of March 2012
  • 5th in Best Web Dev article of February 2012
  • 7th in Best Web Dev article of February 2012
  • 9th in Best Web Dev article of February 2012
  • 5th in Best C++ article of February 2012

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralArticle of the Day on Microsoft's sitemvpRahul Rajat Singh6 Mar '13 - 18:41 
This article has been selected as Article of the Day on Microsoft's site http://www.asp.net/community/articles[^] on 06 February 2013.
 
Rahul Rajat Singh
06 February 2013.

Twenty years from now you will be more disappointed by the things that you didn't do than by the ones you did do. So throw off the bowlines. Sail away from the safe harbor. Catch the trade winds in your sails. Explore, Dream. Discover.

QuestionQuestion regarding adding another members apart from the current membersmemberMember 938693828 Aug '12 - 19:10 
Hi Boss, I understand the code and the design part. It's very good. However, I have a doubt regarding the recepient members for sending message from our end....can we send to any other persons with email Id's or we have to add them before sending emails...
 
if we have to add before sending, then what is the procedure to add them....
Regards
Abhinav
08123077234

AnswerRe: Question regarding adding another members apart from the current membersmemberRahul Rajat Singh28 Aug '12 - 19:23 
Sending mails to actual email ID is not a big task. all the functionality will remain the same. Only when we have pushed the message data into DB we need to use some SMTP server to send this message to an actual email ID.
 
Refer to the following article on how that can be done:
 
Sending Mail Using C# via SMTP[^]
Every now and then say, "What the Elephant." "What the Elephant" gives you freedom. Freedom brings opportunity. Opportunity makes your future.

GeneralMy vote of 3memberAnkit Kumar9 Aug '12 - 23:48 
gud
Questionreal time email applicationmemberbaskaran chellasamy20 Apr '12 - 5:17 
sir, i am new with c# but i would like to create a real time email application.please help me what i need to do from step by step.because once i created this application then almost i will get basic knowledge on c sharp
AnswerRe: real time email applicationmemberRahul Rajat Singh20 Apr '12 - 6:45 
The concept will rwmain same but you will be needin a sntp server an insted of pushing data in db you need to use smtp aend using user credentials. Try with fmail. Its quite straightforward.
GeneralMy vote of 4membersrinivaskumar pasumarthi26 Mar '12 - 23:52 
its good to learn 3-tier architecture mechanism
GeneralMy vote of 1memberFerretallicA24 Mar '12 - 19:02 
This is not even email. Enough said.
GeneralMy vote of 5memberzzymt22 Mar '12 - 23:46 
very nice one. thanks.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web02 | 2.6.130523.1 | Last Updated 20 Apr 2012
Article Copyright 2012 by Rahul Rajat Singh
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid