ASP.NET
  Home arrow ASP.NET arrow Page 3 - Finishing an Online E-Mail System in ASP.N...
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 
Mobile Linux 
App Generation ROI 
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

Finishing 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 / 3
    2007-06-13

    Table of Contents:
  • Finishing an Online E-Mail System in ASP.NET 2.0
  • Deleting Folders
  • Reading Your Email
  • Deleting Your Email
  • Moving Your Email

  • 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


    Finishing an Online E-Mail System in ASP.NET 2.0 - Reading Your Email


    (Page 3 of 5 )

    1. The user interface design

    Now we'll examine how to read e-mail, which is done through the Reader.aspx page. Figure 11 gives its design-time snapshot.

    Figure 11-the design-time snapshot of the Reader.aspx page

    Here we use a table to exhibit the controls and their functions.

    Id

    Control Type

    Function

    To

    TextBox

    The receiver's address (may be more than one)

    CC

    TextBox

    The email address(es) to whom the email is copied

    Title

    TextBox

    Title of the email

    Body

    TextBox

    Body of the email

    AttachView

    GridView

    Used to show the attachment(s) with the email

    ReceiverBtn

    Button

    Reply to the receiver(s) (including those to be copied to)

    ReturnBtn

    Button

    Return to the ViewMail.aspx page

    HtmlCB

    HTML checkbox Button

    Set the format of the email

    2. Initialization

    When initialized, the Reader.aspx page first obtains the parameters named FolderID and MailID from the Request object (which is passed when you click the corresponding hyperlink address of the email in the ViewMail.aspx page):

     

    if(Request.Params["FolderID"] != null)

    {

      if(Int32.TryParse(Request.Params["FolderID"].ToString(),out nFolderID) == false)

      { return;}

    }

    if(Request.Params["MailID"] != null)

    {

      if(Int32.TryParse(Request.Params["MailID"].ToString(),out nMailID) == false)

      { return;}

    }

     

    Next, we will display the content of the specified e-mail.

     

    if(!Page.IsPostBack)

    { ///show the content of the mail

      if(nMailID > -1)

      {

        BindMailData(nMailID);

      }

    }

    private void BindMailData(int nMailID)

    {

      IMail mail = new Mail();

      SqlDataReader dr = mail.GetSingleMail(nMailID);

      if(dr.Read())

      {

        Title.Text = dr["Title"].ToString();

        CC.Text = dr["CCAddress"].ToString();

        To.Text = dr["ToAddress"].ToString();

        Body.Text = dr["Body"].ToString();

        HtmlCB.Checked = bool.Parse(dr["HTMLFormat"].ToString().ToLower());

     

        SqlDataReader drAttach = mail.GetAttachmentsByMail(nMailID);

        AttachView.DataSource = drAttach;

        AttachView.DataBind();

        drAttach.Close();

      }

      dr.Close();

    }

     

    You can see here that we define a helper function named BindMailData which picks out the detailed information about the email from the underlying database according to the nMailID parameter identifying the email. And also, the corresponding attachment is shown from inside the BindMailData function, with a GridView control (AttachView) to display the content of the attachment. Additionally, when you click the 'New Mail' link from inside the draft box, you can view the email in it, too.

    3. Reply and Return

    When you click the Reply button on the page, the control is directed to the  Sender.aspx page:

     

    protected void RecieverBtn_Click(object sender,EventArgs e)

    { ///reply

      Response.Redirect("~/Sender.aspx?MailID=" + nMailID.ToString());

    }

     

    And when you click the Return button, you are navigated back to the ViewMail.aspx page.

    More ASP.NET Articles
    More By Xianzhong Zhu


     

    ASP.NET ARTICLES

    - Disadvantages of the ASP.NET MVC Framework
    - Advantages of the ASP.NET MVC Approach
    - ASP.NET Web Forms Weaknesses
    - ASP.NET Web Forms Meets ASP.NET MVC
    - Source Code for Saving and Retrieving Data w...
    - Using GridView to Save and Retrieve Data wit...
    - Handling Dynamic Images in ASP.NET 3.5 AJAX ...
    - 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





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
    Stay green...Green IT