Creating Your Own Online E-mail System in ASP.NET 2.0
(Page 1 of 4 )
With network technologies developing rapidly, Internet traffic becomes more smooth and feasible. Today, therefore, more people use various online e-mail systems which greatly facilitate them nearly anywhere in the world. In this article, I will show you a rather complicated sample to explain the key techniques behind building such a system entirely with Microsoft ASP.NET 2.0 plus Microsoft SQL Server Express Edition.
A
downloadable .rar file is available for this article.
Since the amount of ground to be covered won't all fit in one article, the material will be covered in four parts. This first part will introduce the topic and dissect the key techniques.
Requirements and Goals
The online e-mail system to be introduced in this series of articles is actually a common online mailbox, with which you can send various kinds of e-mail, such as e-mail in text format, HTML format, and with attachments. Using the system in this series, you will also be able to manipulate your mailboxes and e-mail, such as by looking up the mailboxes and the e-mail in them.
Concretely, the main functions enabled by this system can be enumerated as follows:
Sending common e-mails
Sending HTML-formatted e-mails
Sending e-mails with attachments
Configuring the mail server
Checking your mailboxes
Checking the e-mails in your mailboxes
Creating, renaming and deleting the folders
Reading your e-mails
Deleting your e-mails
Moving your e-mails
Does this sound like a very useful and fun project? The next section will show you how to design the underlining part -- the database tier.
Database Design
With the general goals in mind, we can now focus upon the database design.
Author's Note: Here you're assumed to be familiar with SQL Server 2005 Express Edition and the basic SQL grammar. In addition, to follow along with the example, you'd better download the source files accompanying this article, available in a link immediately after the introduction.
In this article, we'll design a database named WebMailDatabase.mdf, which contains four tables: Folders for holding mailbox folders, Mails for storing all the e-mails, Attachments for storing all the attachments of the related e-mails, and WebMailProfiles for holding information to configure your mail server.
Now, for brevity, the table structures of the four tables are listed in table form respectively as follows:
Table 1-Structure for Folders Table
Field name | Type | Notes |
FolderID | int(4) | Primary Key identifying the record |
Name | varchar(50) | The name of the mailbox |
Total | int(4) | The number of the e-mails contained in this mailbox |
NoReader | int(4) | The number of the unread e-mails |
Contain | int(4) | The size of the mailbox |
CreateDate | datetime(8) | Tells when the mailbox was created |
Flag | bit(1) | Marks whether it's a self-defined mailbox |
Table 2-Structure for Mails Table
Field name | Type | Notes |
MailID | int(4) | ID(Primary Key) |
Title | varchar(255) | The title of the e-mail |
Body | text(16) | The body of the e-mail |
FromAddress | text(16) | The sender list of the e-mail |
ToAddress | text(16) | The receiver list of the e-mail |
CCAdress | text(16) | The CC list of the e-mail |
HTMLFormat | bit(1) | Specifies whether it is an HTML-formatted e-mail |
SenderDate | datetime(8) | The send date list of the e-mail |
Contain | int(4) | The size of the mailbox |
AttachmentFlag | bit(1) | Specifies whether there are attachments in this e-mail |
ReaderFlag | bit(1) | Specifies whether this e-mail has been read |
FolderID | int(4) | ID of the related mailbox |
Table 3-Structure for Attachments Table
Field name | Type | Notes |
AttachmentID | int(4) | ID(Primary Key) |
Name | varchar(50) | The name of the attachment |
Url | varchar(255) | linking address of the attachment |
Type | varchar(50) | Type of attachment |
Contain | int(4) | size of the attachment |
MailID | int(4) | The ID of its related e-mail |
Table 4-Structure for WebMailProfiles Table
Field name | Type | Notes |
WebMailID | int(4) | ID(Primary Key) |
UserName | varchar(50) | The user name |
AliasName | varchar(50) | The alias name of the user |
Email | varchar(255) | The e-mail address of the user |
MailServerIP | varchar(50) | The ID address of the mail server |
MailServerPort | int(4) | The port of the mail server |
Besides these four tables, we've also defined three stored procedures, namely Pr_DeleteMail, Pr_MoveMail and Pr_SaveAsMail used to delete the e-mails, move the e-mails and save the e-mails sent out, respectively. Here we don't list their relevant sql scripts, since there is still a long journey for us to make. For all detailed information, please refer to the downloadable source files accompanying this article.
Next: Dissecting the Key Techniques: Interface Design >>
More ASP.NET Articles
More By Xianzhong Zhu