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 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
Your Filters
Interested
Ignored
     
0 Shai Vashdi 1,518
1 OriginalGriff 383
2 Manas Bhardwaj 324
3 Tadit Dash 305
4 Peter Leow 255
0 Sergey Alexandrovich Kryukov 9,575
1 OriginalGriff 5,856
2 Peter Leow 4,405
3 Maciej Los 3,540
4 Abhinav S 3,513


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