error in sending mail
<p>using System;
    using System.Collections;
    using System.Configuration;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Linq;
    using System.Net.Mail;</p>

<pre><code>public partial class adminEmail : System.Web.UI.Page
{
    string address = null;
    string to = null;
    protected void Page_Load(object sender, EventArgs e)
    {
        for (int i = 0; i &lt; GridView1.Rows.Count; i++)
        {
            if (address == null)
                address = GridView1.Rows[0].Cells[1].Text;

            else
                address = address + "," + GridView1.Rows[i].Cells[1].Text;
            Label2.Text = address;
            string to = address;
            txtTo.Text = to;
        }

    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {



        string from = ".com"; //Replace this with your own correct Gmail Address


        //Replace this with the Email Address to whom you want to send the mail

        Label1.Text = "Mail sent successfully";
        Label1.Visible = true;
        MailMessage mail = new System.Net.Mail.MailMessage();
        Label2.Text = address;

       /*gettting error here*/ mail.To.Add(new MailAddress(to));
        mail.From = new MailAddress(from, "Check My Ads", System.Text.Encoding.UTF8);
        mail.Subject = txtSubject.Text;
        mail.SubjectEncoding = System.Text.Encoding.UTF8;
        mail.Body = Editor1.ScriptPath;
        mail.BodyEncoding = System.Text.Encoding.UTF8;
        mail.IsBodyHtml = true;
        mail.Priority = MailPriority.High;

        SmtpClient client = new SmtpClient();
        //Add the Creddentials- use your own email id and password

        client.Credentials = new System.Net.NetworkCredential(from, "password");

        client.Port = 587; // Gmail works on this port
        client.Host = "smtp.gmail.com";
        client.EnableSsl = true; //Gmail works on Server Secured Layer
        try
        {
            client.Send(mail);
        }
        catch (Exception ex)
        {
            Exception ex2 = ex;
            string errorMessage = string.Empty;
            while (ex2 != null)
            {
                errorMessage += ex2.ToString();
                ex2 = ex2.InnerException;
            }

        }
    }
    protected void btnCancel_Click(object sender, EventArgs e)
    {

    }
}
</code></pre>

<p>and my .aspx code</p>

<pre><code>&lt;%@ Page Language="C#" MasterPageFile="~/Admin.master" AutoEventWireup="true" CodeFile="adminEmail.aspx.cs" Inherits="adminEmail" Title="Untitled Page" %&gt;

&lt;%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit.HTMLEditor"
    TagPrefix="cc1" %&gt;

&lt;%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %&gt;

&lt;%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"  Namespace="System.Web.UI" TagPrefix="asp" %&gt;



&lt;asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"&gt;
    &lt;asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"&gt;
    &lt;/asp:ToolkitScriptManager&gt;
        &lt;div&gt;
        &lt;center&gt;
            &lt;table style="width: 652px; height: 504px"&gt;
                &lt;tr&gt;
                    &lt;td   colspan="2"&gt;
                        &lt;span style="color: activecaption"&gt;&lt;strong&gt;&lt;em&gt;&lt;span style="font-size: 16pt"&gt;
                        Mail Sender&lt;/span&gt;&lt;/em&gt;&lt;/strong&gt;
                        &lt;/span&gt;
                    &lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                    &lt;td style="height: 26px" &gt;
                        &lt;strong&gt;&lt;span style="color: activecaption"&gt;
                        Enter UserName&lt;/span&gt;&lt;/strong&gt;
                    &lt;/td&gt;
                    &lt;td align=left style="height: 26px"&gt;
                        &lt;asp:TextBox ID="txtUserName" runat="server" Width="169px"&gt;&lt;/asp:TextBox&gt;
                    &lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                    &lt;td&gt;
                        &lt;strong&gt;&lt;span style="color:Gray"&gt;&lt;span style="color: activecaption"&gt;
                        Enter Password&lt;/span&gt; &lt;/span&gt;&lt;/strong&gt;
                    &lt;/td&gt;
                    &lt;td align=left&gt;
                        &lt;asp:TextBox ID="txtPassword" runat="server" TextMode="Password" Width="168px"&gt;&lt;/asp:TextBox&gt;
                    &lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                    &lt;td&gt;
                        &lt;strong&gt;&lt;span style="color: activecaption"&gt;
                        To:&lt;/span&gt;&lt;/strong&gt;
                    &lt;/td&gt;
                    &lt;td align=left&gt;
                        &lt;asp:TextBox ID="txtTo" runat="server" Width="169px" Height="22px"&gt;&lt;/asp:TextBox&gt;
                    &lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                    &lt;td&gt;
                        &lt;strong&gt;&lt;span style="color: activecaption"&gt;
                        Subject:&lt;/span&gt;&lt;/strong&gt;
                    &lt;/td&gt;
                    &lt;td align=left&gt;
                        &lt;asp:TextBox ID="txtSubject" runat="server" Width="168px"&gt;&lt;/asp:TextBox&gt;
                    &lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                    &lt;td&gt;
                        &lt;strong&gt;&lt;span style="color: activecaption"&gt;
                        Body: &lt;/span&gt;&lt;/strong&gt;
                    &lt;/td&gt;
                    &lt;td align="left"&gt;
                        &lt;cc1:Editor ID="Editor1" runat="server" ButtonMouseOverBorderColor="GradientInactiveCaption" ButtonMouseOverColor="ActiveCaption" DialogButtonBarColor="ActiveCaption" DialogHeadingColor="ActiveCaption" DialogSelectedTabColor="ActiveCaption" DialogUnselectedTabColor="ActiveCaption" EditorBorderColor="ActiveCaption" SelectedTabBackColor="ActiveCaption" SelectedTabTextColor="InactiveCaptionText" TabBackColor="ActiveCaption" TabMouseOverColor="GradientActiveCaption" ToolbarColor="GradientActiveCaption" /&gt;
                        &amp;nbsp;&amp;nbsp;
                    &lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                    &lt;td colspan="2"&gt;
                        &lt;asp:Button ID="btnSubmit" runat="server" Text="SUBMIT" Font-Bold="True" ForeColor="ActiveCaption" OnClick="btnSubmit_Click" /&gt;
                           &lt;asp:Button ID="btnCancel" runat="server" Text="RESET" CausesValidation="False" Font-Bold="True" ForeColor="ActiveCaption" OnClick="btnCancel_Click" UseSubmitBehavior="False" /&gt;
                        &lt;br /&gt;
                        &lt;br /&gt;
                        &lt;br /&gt;
                        &lt;asp:Label ID="Label1" runat="server" Text="Label" Visible=false&gt;&lt;/asp:Label&gt;
                        &lt;br /&gt;
                        &lt;br /&gt;
                        &lt;br /&gt;
                        &lt;br /&gt;
                        &lt;asp:Label ID="Label2" runat="server" Text="Label"&gt;&lt;/asp:Label&gt;
                        &lt;asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
                            DataKeyNames="username" DataSourceID="SqlDataSource1" Width="223px"&gt;
                            &lt;Columns&gt;
                                &lt;asp:BoundField DataField="username" HeaderText="username" ReadOnly="True" 
                                    SortExpression="username" /&gt;
                                &lt;asp:BoundField DataField="emailid" HeaderText="emailid" 
                                    SortExpression="emailid" /&gt;
                                &lt;asp:BoundField DataField="gender" HeaderText="gender" 
                                    SortExpression="gender" /&gt;
                            &lt;/Columns&gt;
                        &lt;/asp:GridView&gt;
                        &lt;asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                            ConnectionString="&lt;%$ ConnectionStrings:eclassConnectionString2 %&gt;" 
                            SelectCommand="SELECT [username], [emailid], [gender] FROM [userdetails] WHERE ([status_user] = @status_user)"&gt;
                            &lt;SelectParameters&gt;
                                &lt;asp:Parameter DefaultValue="new" Name="status_user" Type="String" /&gt;
                            &lt;/SelectParameters&gt;
                        &lt;/asp:SqlDataSource&gt;
                    &lt;/td&gt;

                &lt;/tr&gt;
            &lt;/table&gt;
            &lt;/center&gt;
        &lt;/div&gt;
&lt;/asp:Content&gt;
</code></pre>

<p>please do tell me what is my fault</p>
