The .NET Project - Design a User Form for an Email Client

Send Email Walkthrough: for C# and VB NET Students


In this project, you'll write your own email client. You'll learn how to send emails and how to receive them. This is an intermediate project and is for students of Visual Basic .Net and C# .Net. Let's make a start.

Create a new Windows Form project for this. Call it anything you like. Add a TabControl to your new form. The TabControl is in the Containers section:

The Visual Studio Toolbox showing the TabControl highlighted

Shortly, we'll resize the TabControl so that it takes up the whole of the form. For now, make sure that the TabControl itself is select and not just a tab page. The top of the Properties window should say tabControl1 and not tabPage1. To make sure, don't click in the big white area but on the tab itself, right at the top.

With the TabControl selected, locate the TabPages property:

Properties of the TabControl showing the TabPages item selected

Now click the button on the right, the one with the three dots in it. You should see a dialog box appear. This one:

The TabPage Collection Editor in Visual Studio

This is the TabPage Collection Editor, where you can change properties about a specific tab. Let's change the default text at the top.

With the tabPage1 item selected under Members on the left, locate the Text property. Change it to Send Emails:

The TabPage Collection Editor showing tabPage1 being renamed to Send Emails

Now select tabPage2 under Members and change the Text property to Receive Emails:

The TabPage Collection Editor showing tabPage2 being renamed to Receive Emails

Click OK and the top of your tabs will be renamed.

Now Dock the TabControl by locating the Dock property. Change it to Fill by clicking the big button in the middle:

The Properties panel in Visual Studio showing how to resize a TabControl using Dock

Run your form. Change its size and you should find that the tabs resize, which is what the Dock property does for you:

A Windows Form in Visual Studio with a TabControl

Now add the following controls to your Send Email Tab:

Name: txtEmailTo
Text: An Email Address of your Choice

Name: txtEmailFrom
Text: An Email Address of your Choice

Name: txtEmailSubject
Text: Any Text of your Choice

Name: txtEmailBody
Text: Blank
MultiLine: True

Label 1
Text: TO:

Label 2
Text: FROM:

Label 3

Name: BtnSend
Text: Send Email

When you've finished adding all the controls, it should look something like this:

A Windows Form with tabs designed for sending emails

With the form designed, we can start on the coding. We'll start in the next lesson below.

Set up the SMTP Client >>

Back to the C# NET Contents Page

Back to the VB NET Contents Page