Tuesday 22 January 2013

How To Send Email Using Asp.net with C#

This is the tutorial for sending the simple email using the asp.net with C#. For this we use this the SMTP of Gmail. Before starting the tutorial you should have a Google Account and if you don't have on you can easily create a free account from here.

Now you have to create a simple web form in Visual Studio as shown in the figure. The code of the following web form is given below.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        .style1
        {
            width: 100%;
        }
        .style2
        {
            width: 156px;
        }
        .style3
        {
            width: 156px;
            text-align: right;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
   
        <table class="style1">
            <tr>
                <td class="style3">
                    Gmail Address</td>
                <td>
                    <asp:TextBox ID="TextBox1" runat="server" Width="255px"></asp:TextBox>
                    <asp:RegularExpressionValidator ID="RegularExpressionValidator4" runat="server"
                        ControlToValidate="TextBox1" ErrorMessage="Valid Email Address..."
                        ForeColor="Red"
                        ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
                </td>
            </tr>
            <tr>
                <td class="style3">
                    Gmail password</td>
                <td>
                    <asp:TextBox ID="TextBox2" runat="server" Width="255px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="style3">
                    To</td>
                <td>
                    <asp:TextBox ID="TextBox3" runat="server" Width="255px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="style3">
                    Subject</td>
                <td>
                    <asp:TextBox ID="TextBox4" runat="server" Width="400px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="style3">
                    Message</td>
                <td>
                    <asp:TextBox ID="TextBox5" runat="server" Height="74px" TextMode="MultiLine"
                        Width="400px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="style2">
                    <asp:Button ID="Button1" runat="server" onclick="Button1_Click"
                        Text="Send Mail" />
                </td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td class="style2">
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td class="style2">
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td class="style2">
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
        </table>
   
    </div>
    </form>
</body>
</html>



Now your web form is complete and the only task which is remaining is applying the Mail Sending function on the event of Button Click. Before applying the code in the .CS file you have to include following header files on it.

using System.Net;
using System.Net.Mail;

Now the code for sending the mail is given as follows:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.Net.Mail;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        MailMessage msg = new MailMessage();
        msg.From = new MailAddress(TextBox1.Text, "Senders Name");
        msg.To.Add(new MailAddress(TextBox3.Text));
        msg.Subject = TextBox4.Text;
        msg.Body = TextBox5.Text;
        msg.IsBodyHtml = true;

        SmtpClient smtp = new SmtpClient();
        smtp.Host = "smtp.gmail.com";
        smtp.Credentials = new NetworkCredential(TextBox1.Text, TextBox2.Text);
        smtp.EnableSsl = true;
        smtp.Send(msg);

    }
}
 
 

Now just compile and run the code. 

Saturday 24 November 2012

Email System Project using Asp.net with C#

The Email System Project explores the features of an email system developed in a simple manner and shows how to create a simple mail service using asp.net technology. The email service and the concepts behind the mail server which is based on SMTP. The project is based on the asp.net and C# and before starting the project you have to install the Visual Studio and IIS server on your system.

SMTP stands for Simple Mail Transfer Protocol. The emails are sent using this perfect protocol. The .NET Framework supplies the SMTP class that enables you to send simple e-mail messages. If you have to send an e-mail with added functionalities, you have to make use of the MailMessage class. With the help of this class, you can insert attachments, set priorities, etc. very easily. You can also send HTML e-mail using this class.

Download Source Code....DOWNLOAD HERE

Inventory Management Project in Asp.Net with C#

Inventory management project is a computer-based system for tracking inventory levels, orders, sales and deliveries. It can also be used in the manufacturing industry to create a work order, bill of materials and other production-related documents. Companies use inventory management software to avoid product overstock and outages. It is a tool for organizing inventory data that before was generally stored in hard-copy form or in spreadsheets.

Order management

Should inventory reach a certain threshold, a company's inventory management system can be programmed to tell managers to reorder that product. This helps companies avoid running out of products or tying up too much capital in inventory.

Asset tracking

When a product is in a warehouse or store, it can be tracked via its barcode and/or other tracking criteria, such as serial number, lot number or revision number. Nowadays, inventory management software often utilizes barcode, radio-frequency identification (RFID), and/or wireless tracking technology.

Service management

Companies that are primarily service-oriented rather than product-oriented can use inventory management software to track the cost of the materials they use to provide services, such as cleaning supplies. This way, they can attach prices to their services that reflect the total cost of performing them.

Product identification

Barcodes are often the means whereby data on products and orders is inputted into inventory management software. A barcode reader is used to read barcodes and look up information on the products they represent. Radio-frequency identification (RFID) tags and wireless methods of product identification are also growing in popularity.


Download Project Source Code with Documentation... DOWNLOAD HERE