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 9:36am
Edited 6-Oct-12 9:38am
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
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

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

  Print Answers RSS
0 Peter Leow 295
1 Mika Wendelius 275
2 CHill60 190
3 TheRealSteveJudge 180
4 Rob Philpott 130
0 Sergey Alexandrovich Kryukov 8,613
1 OriginalGriff 6,581
2 Peter Leow 3,962
3 Zoltán Zörgő 3,480
4 Richard MacCutchan 2,502


Advertise | Privacy | Mobile
Web04 | 2.8.150123.1 | Last Updated 6 Oct 2012
Copyright © CodeProject, 1999-2015
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