Create A Communications Application In ASP.NET 4.5.2 Using Visual Studio 2015

Introduction

In this article, you will learn how to create communications applications, like an email applications, using C#, ASP.NET, and Visual Studio 2015 Update 3.

Requirements
  • Visual Studio 2015 Update 3
  • ASP.NET 4.5.2

If you want to develop communications applications, you should follow the steps, mentioned below.

Step 1

Open Visual Studio 2015 Update 3, go to the File >> New >> Project. Or, use the shortcut key - "Ctrl+Shift +N".

ASP.Net

Step 2

Now, select Visual C# >> Web >> ASP.NET Web Application. Finally, click "OK" button.

ASP.Net

Step 3

Here, you can select the template  for your ASP.NET application. We are choosing "Empty" here. Now, click OK button.

ASP.Net

Step 4

Now, open the project and look for the  Solution Explorer .

ASP.Net

Step 5

Here, open the default .aspx. If you want a Web form, you can add the page (Web form) Add+New item (Ctrl+Shift+A).

ASP.Net

Step 6

Now, we can build the design using drag and drop method. Open the toolbox, if you want some options there. It should be like the textbox, label, and so on.

ASP.Net

Step 7

Here is the default.aspx code.

Default.aspx code

  1. <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="communi.aspx.cs" Inherits="communication.communi" %>  
  2.     <!DOCTYPE html>  
  3.     <html xmlns="http://www.w3.org/1999/xhtml">  
  4.   
  5.     <head runat="server">  
  6.         <title></title>  
  7.         <link href="style.css" rel="stylesheet" type="text/css" />  
  8.         <style type="text/css">  
  9.             .auto-style1 {  
  10.                 width: 100%;  
  11.             }  
  12.         </style>  
  13.     </head>  
  14.   
  15.     <body>  
  16.         <form id="form1" runat="server">  
  17.             <div id="from">  
  18.                 <h1>ASP.Net COMMUNICATION APPLICATION</h1>  
  19.             </div>  
  20.             <div id="fromone">  
  21.                 <table class="auto-style1">  
  22.                     <tr>  
  23.                         <td>  
  24.                             <asp:Label ID="Label1" runat="server" Text="To(E-Mail Address)"></asp:Label>  
  25.                         </td>  
  26.                         <td>  
  27.                             <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>  
  28.                         </td>  
  29.                     </tr>  
  30.                     <tr>  
  31.                         <td>  
  32.                             <asp:Label ID="Label" runat="server" Text="Subject"></asp:Label>  
  33.                         </td>  
  34.                         <td>  
  35.                             <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>  
  36.                         </td>  
  37.                     </tr>  
  38.                 </table> <br />  
  39.                 <asp:Label ID="Label2" runat="server" Text="Message"></asp:Label><br />  
  40.                 <asp:TextBox ID="TextBox3" TextMode="MultiLine" runat="server" Height="82px" Width="357px"></asp:TextBox><br />  
  41.                 <asp:Button ID="Button1" runat="server" Text="SEND" /><br />  
  42.                 <asp:Label ID="Label3" runat="server" Text="Label"></asp:Label>  
  43.             </div>  
  44.         </form>  
  45.     </body>  
  46.   
  47.     </html>  
Step 8

Now, first of all, declare the header file, because this project is based on SMTP (Simple Mail Transfer Protocol). 

using System.Net.Mail;

Here, fill in the C# code.
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Linq;  
  4. using System.Web;  
  5. using System.Web.UI;  
  6. using System.Web.UI.WebControls;  
  7. using System.Net.Mail;  
  8. namespace communication {  
  9.     public partial class communi: System.Web.UI.Page {  
  10.         protected void Page_Load(object sender, EventArgs e) {}  
  11.         protected void Button1_Click(object sender, EventArgs e) {  
  12.             SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");  
  13.             SmtpServer.Port = 587;  
  14.             SmtpServer.Credentials = new System.Net.NetworkCredential("[email protected]""muthu@123");  
  15.         }  
  16.     }  
  17. }  
Step 9

Here, you can see the output.

ASP.Net

Step 10

Afterwards, add the File upload option in the Communication application.

Now, add the FileUpload control. Make use of the drag method.

ASP.Net

Step 11

Here, you can see the C# code.

Step 12

Now, you can see default.aspx code.

<asp:FileUpload ID="FileUpload1" runat="server" />

Step 13 

Now, you have the option of mailing with file upload feature.

ASP.Net

The file is uploaded and you can see the final output.

ASP.Net

 

Up Next
    Ebook Download
    View all
    Learn
    View all