Click here to Skip to main content
15,890,506 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to write code for generating email in asp.net with c# .net
Posted
Comments
Shubh Agrahari 7-Feb-13 3:54am    
what you actually want...can more clarify....its for your better help
Member 9794156 7-Feb-13 3:57am    
what is the c# code for sending a mail from asp.net web page
Kishor Deshpande 7-Feb-13 4:24am    
Well, I've posted code, try it once and let me know if you face any issue...
Have you tried Googling and implemented anything yet?
Just implement these example codes and try to learn.

If you face any problems, then please come back with your query.
Shubh Agrahari 7-Feb-13 4:06am    
ya Tadit is right just goggle 1st belive that helps you.

Did you read this[^] before posting your question here?

Send Email in ASP.Net 2.0[^]
Sending email from ASP.Net 4 – C# sample code[^]

there are plenty of examples in Google.Dont believe me.Checkit[^]
 
Share this answer
 
C#
protected void SendMail()
  {
      // Gmail Address from where you send the mail
      var fromAddress = "google@gmail.com";
      // any address where the email will be sending
      var toAddress = "info@gmail.com";
      //Password of your gmail address
      const string fromPassword = "123456789";
      // Passing the values and make a email formate to display
      string subject = TextBox3.Text.ToString();
      string body = "From: " + txtname.Text + "\n";
      body += "Email: " + txtemail.Text + "\n";
      body += "Mobile: " + txtsubject.Text + "\n";
      body += "Message: \n" + txtmsg.Text + "\n";
      // smtp settings
      var smtp = new System.Net.Mail.SmtpClient();
      {
          smtp.Host = "smtp.gmail.com";
          smtp.Port = 587;
          smtp.EnableSsl = true;
          smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
          smtp.Credentials = new NetworkCredential(fromAddress, fromPassword);
          smtp.Timeout = 20000;
      }
      // Passing values to smtp object
      smtp.Send(fromAddress, toAddress, subject, body);
  }
 
Share this answer
 
 
Share this answer
 

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