Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to send email on the button click can anybody tell me how i can becoz its showing an error the specified string is not in the email format
C#
protected void submitbtn1_Click(object sender, ImageClickEventArgs e)
{
    SmtpClient smtpclient = new SmtpClient();
    MailMessage mailmessage = new MailMessage();

    MailAddress emailsenderaddress = new MailAddress(Usernametxtbx.Text, chngepswdtxt.Text);
    smtpclient.Host = "smtp.gmail.com";
    smtpclient.Port = 587;
    mailmessage.From = emailsenderaddress;
    MailAddress recepient = new MailAddress("abhimanyu.vij@gmail.com");
    mailmessage.To.Add("recepient");
    smtpclient.Send(mailmessage);
}
Posted
Updated 6-Oct-12 8:38am
v2

This line of code looks a little bit confusing:
C#
MailAddress emailsenderaddress = new MailAddress(Usernametxtbx.Text, chngepswdtxt.Text);

Usernametxtbx and chngepswdtxt looks not email address fields to me...
 
Share this answer
 
v2
You didn't specify any subject and body.
mailmessage.Subject = "Your subject";
mailmessage.Body = "Your Body";


cheers
 
Share this answer
 
v3
C#
MailAddress emailsenderaddress = new MailAddress(Usernametxtbx.Text,emailtxtbx.Text);

now its ok here i have two txtbx one s one is for username and one is for email got it now tell me the solution
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900