ASP.NET
  Home arrow ASP.NET arrow Page 2 - Designing the Interface and More for an On...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Moblin 
JMSL Numerical Library 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP.NET

Designing the Interface and More for an Online E-Mail System in ASP.NET 2.0
By: Xianzhong Zhu
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 5
    2007-06-12

    Table of Contents:
  • Designing the Interface and More for an Online E-Mail System in ASP.NET 2.0
  • Designing the Data Tier
  • Check Your Mailbox List
  • Check the E-mails in Your Mailbox
  • Creating Folders

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Designing the Interface and More for an Online E-Mail System in ASP.NET 2.0 - Designing the Data Tier


    (Page 2 of 5 )

    In fact, alert readers may have sensed that this sample system is composed of a typical three-tier structure: the web pages correspond to the representation tier, the interfaces defined above are associated with the logic tier, and the SQL Server database is related to the data tier. The data access tier (the logic tier) of the whole system mainly lies in two classes: Folder and Mail depicted above, along with an auxiliary class, named WebMailProfile (in fact a struct) to hold the system profile information. And with further digging, you can easily find that the WebMailProfile class is closely connected with two methods (GetWebMailProfile and WebMailProfile) defined in the Mail class. The sketch in Figure 5 gives us a more vivid depiction on the relationships between the modules we'll use:

    Figure 5-the sketch shows the relationships between the modules

    Here, for brevity, we choose to omit all other methods for there are so many of them (see the downloadable source code for detail). However, I want to single out a representative method, named SaveAsMail of the Mail class, to give the typical implementation of the logic tier above. The following lists the complete source code of the SaveAsMail method:

     

    public int SaveAsMail(string sTitle,string sBody,string sFrom,string sTo,

          string sCC,bool bHtmlFormat,int nContain,bool bAttachmentFlag)

      {

        ///open the link to the database

        SqlConnection myConnection = new SqlConnection(

          ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRING"].ConnectionString);

        SqlCommand myCommand = new SqlCommand("Pr_SaveAsMail",myConnection);

        myCommand.CommandType = CommandType.StoredProcedure;

        ///give the parameters of the stored procedure

        SqlParameter pTitle = new SqlParameter("@Title",SqlDbType.VarChar,200);

        pTitle.Value = sTitle;

        myCommand.Parameters.Add(pTitle);

        SqlParameter pBody = new SqlParameter("@Body",SqlDbType.Text,2147483647);

        pBody.Value = sBody;

        myCommand.Parameters.Add(pBody);

        SqlParameter pFrom = new SqlParameter("@FromAddress",SqlDbType.Text,2147483647);

        pFrom.Value = sFrom;

        myCommand.Parameters.Add(pFrom);

        SqlParameter pTo = new SqlParameter("@ToAddress",SqlDbType.Text,2147483647);

        pTo.Value = sTo;

        myCommand.Parameters.Add(pTo);

        SqlParameter pCC = new SqlParameter("@CCAddress",SqlDbType.Text,2147483647);

        pCC.Value = sCC;

        myCommand.Parameters.Add(pCC);

        SqlParameter pHtmlFormat = new SqlParameter("@HtmlFormat",SqlDbType.Bit,1);

        pHtmlFormat.Value = bHtmlFormat.ToString();

        myCommand.Parameters.Add(pHtmlFormat);

        SqlParameter pContain = new SqlParameter("@Contain",SqlDbType.Int,4);

        pContain.Value = nContain;

        myCommand.Parameters.Add(pContain);

        SqlParameter pAttachmentFlag = new SqlParameter("@AttachmentFlag",SqlDbType.Bit,1);

        pAttachmentFlag.Value = bAttachmentFlag.ToString();

        myCommand.Parameters.Add(pAttachmentFlag);

        SqlParameter pMailID = new SqlParameter("@MailID",SqlDbType.Int,4);

        pMailID.Direction = ParameterDirection.ReturnValue;

        myCommand.Parameters.Add(pMailID);

        ///define the returned data

        int nResult = -1;

        try

        {

          ///open the link

          myConnection.Open();

          ///execute the SQL clause

          nResult = myCommand.ExecuteNonQuery();

        }

        catch(SqlException ex)

        {

          ///throw exception

          throw new Exception(ex.Message,ex);

        }

        finally

        { ///close the link

          myConnection.Close();

        }

        ///return nResult

        return(int)myCommand.Parameters[8].Value;

      }

     

    In this method, the e-mail that has just been sent out is to be saved in the mailbox. First of all, we create and open a link to the SQL Server database (the linking string is defined in the web.config file). Second, we get ready to invoke the Pr_SaveAsMail stored procedure defined in the previous Database Design section by populating the parameters of the ASP.NET built-in objects SqlCommand and SqlParameter. Third, we execute the SQL clause to perform the real task within a safer try block. And finally, we return some according the method definition. It's a seemingly long, but indeed a typical database operation in the logic tier, isn't it?

    So much for the lower development! Starting with the next section, we'll examine the presentation tier design.

    More ASP.NET Articles
    More By Xianzhong Zhu


       · HiThis e mail system does not read from my configured pop3 account.It just shows...
       · Hi my friend there,I'm willing to help you out. When I debugged this sample the...
     

    ASP.NET ARTICLES

    - Retrieving Data with AJAX and the GridView C...
    - Playing with Images in ASP.NET 3.5 AJAX Appl...
    - Saving and Retrieving Data with AJAX
    - Enhancing PHP Via the ASP.NET AJAX Framework...
    - Enhancing PHP Programming with the ASP.NET A...
    - Classes and ASP.NET AJAX
    - Using ASP.NET AJAX
    - Building a Simple Storefront with LINQ
    - Developing a Dice Game Using ASP.NET Futures...
    - Completing an ASP.NET AJAX Server-Centric Ba...
    - Information Management for an ASP.NET AJAX S...
    - Comment and Order Management for an ASP.NET ...
    - Back-end Management Tasks for an ASP.NET AJA...
    - User Information Management for an ASP.NET A...
    - Adding Comments and Search to an ASP.NET AJA...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway