Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
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
        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 6-Oct-12 8:36am
Edited 6-Oct-12 8:38am
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

This line of code looks a little bit confusing:
MailAddress emailsenderaddress = new MailAddress(Usernametxtbx.Text, chngepswdtxt.Text);
Usernametxtbx and chngepswdtxt looks not email address fields to me...
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

You didn't specify any subject and body.
mailmessage.Subject = "Your subject";
mailmessage.Body = "Your Body";
 
cheers
  Permalink  
v3

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

  Print Answers RSS
0 OriginalGriff 6,249
1 Sergey Alexandrovich Kryukov 5,680
2 CPallini 4,850
3 George Jonsson 3,454
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 6 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100