try
{
string to = "help@xxx.com";
string from = "help@xxx.com";
string subject = "Help";
string body = "First name:- " + txtFirstName.Text + Environment.NewLine + "Last Name :-" + txtLastName.Text + Environment.NewLine + "Email:- " + txtEmail.Text + Environment.NewLine + "Ph No:- " + txtMobileNo.Text + Environment.NewLine + "Messsage:-" + txtPleasefeel.Text.Trim();
MailMessage message = new MailMessage(from, to, subject, body);
SmtpClient client = new SmtpClient("smtp.gmail.com",587);
client.EnableSsl = true;// enable must in webconfig file
client.UseDefaultCredentials = true;
client.Credentials = new NetworkCredential("help@xxx.com","password"); // password-as ur
client.Send(message);
litStatus.Text = "Sent Successfully...";
txtFirstName.Text = "";
txtMiddleName.Text = "";
txtLastName.Text = "";
txtEmail.Text = "";
txtMobileNo.Text = "";
txtPleasefeel.Text = "";
}
catch (Exception ex)
{
litStatus.Visible = true;
litStatus.Text = "Server OverLoaded...";
}
///////////////////////////////////////////
in web config file at last
<system.diagnostics>
<trace autoflush="true" />
<sources>
<source name="System.Net" >
<listeners>
<add name="MyTraceFile"/>
</listeners>
</source>
<source name="System.Net.Sockets">
<listeners>
<add name="MyTraceFile"/>
</listeners>
</source>
</sources>
<sharedListeners>
<add
name="MyTraceFile"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="System.Net.trace.log" />
</sharedListeners>
<switches>
<add name="System.Net" value="Verbose" />
<add name="System.Net.Sockets" value="Verbose" />
</switches>
</system.diagnostics>