By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,667 Members | 2,603 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,667 IT Pros & Developers. It's quick & easy.

I want send Info on particular E-Mail ID when click on send button on form in ASP .Ne

P: 1
I want send Info on particular E-Mail ID when click on send button on form in ASP .Net [in C#] .
Nov 29 '12 #1
Share this Question
Share on Google+
2 Replies


P: 31
HI ! i am not sure that it will help you perfectly but i tried for little-bit help you.

Expand|Select|Wrap|Line Numbers
  1. protected void SendMail()
  2. {
  3.     // Gmail Address from where you send the mail
  4.     var fromAddress = "Gmail@gmail.com";
  5.     // any address where the email will be sending
  6.     var toAddress = YourEmail.Text.ToString(); 
  7.     //Password of your gmail address
  8.     const string fromPassword = "Password";
  9.      // Passing the values and make a email formate to display
  10.     string subject = YourSubject.Text.ToString();
  11.     string body = "From: " + YourName.Text + "\n";
  12.     body += "Email: " + YourEmail.Text + "\n";
  13.     body += "Subject: " + YourSubject.Text + "\n";
  14.     body += "Question: \n" + Comments.Text + "\n";
  15.     // smtp settings
  16.     var smtp = new System.Net.Mail.SmtpClient();
  17.     {
  18.         smtp.Host = "smtp.gmail.com";
  19.         smtp.Port = 587;
  20.         smtp.EnableSsl = true;
  21.         smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
  22.         smtp.Credentials = new NetworkCredential(fromAddress, fromPassword);
  23.         smtp.Timeout = 20000;
  24.     }
  25.     // Passing values to smtp object
  26.     smtp.Send(fromAddress, toAddress, subject, body);
  27. }
  28.  
  29. protected void Button1_Click(object sender, EventArgs e)
  30. {
  31.     try
  32.     {
  33.         //here on button click what will done 
  34.         SendMail();
  35.         DisplayMessage.Text = "Your Comments after sending the mail";
  36.         DisplayMessage.Visible = true;
  37.         YourSubject.Text = "";
  38.         YourEmail.Text = "";
  39.         YourName.Text = "";
  40.         Comments.Text = "";
  41.     }
  42.     catch (Exception) { }
  43. }
Nov 29 '12 #2

Frinavale
Expert Mod 5K+
P: 9,731
There is an insight here on Bytes titled: Quick Reference on how to send an email using .NET that will get you pointed in the right direction.


-Frinny
Dec 4 '12 #3

Post your reply

Sign in to post your reply or Sign up for a free account.