943,572 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 1076
  • ASP.NET RSS
May 7th, 2009
0

Contact form

Expand Post »
Hi, I'm trying to make a contact form, but it won't send the e-mail when I press send.
It doesn't make an error, just nothing happens.
I really don't know what the problem can be.
I'm doing it in .net c#

here is my code from my cs page:

ASP.NET Syntax (Toggle Plain Text)
  1.  
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using System.Data.SqlClient;
  8. using System.Data;
  9. using System.Configuration;
  10. using System.Collections;
  11. using System.Web.Security;
  12. using System.Web.UI.WebControls.WebParts;
  13. using System.Web.UI.HtmlControls;
  14. using System.Net.Mail;
  15.  
  16. public partial class dkkontakt : System.Web.UI.Page
  17. {
  18. protected void Page_Load(object sender, EventArgs e)
  19. {
  20.  
  21. }
  22.  
  23. protected void submit_click(object sender, EventArgs e)
  24. {
  25. MailMessage Emailmsg = new MailMessage("noreply@hotmail.com", "mymail@hotmail.com");
  26. Emailmsg.Subject = "Kontaktform";
  27. Emailmsg.Body += "E-mail" + email.Text;
  28. Emailmsg.Body += "Navn: " + name.Text;
  29. Emailmsg.Body += "Tekst: " + besked.Text;
  30.  
  31.  
  32.  
  33. }
  34.  
  35. }


Hope someone can see the problem and help me?

thanks
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
kischi is offline Offline
62 posts
since Dec 2008
May 7th, 2009
0

Re: Contact form

Hi try this
string email = "Your@email.com";
MailMessage message = new MailMessage();
message.From = new MailAddress(email);
message.To.Add("recipient@email.com");
message.Subject = "Subject";
message.Body = "Body";
SmtpClient emailClient = new SmtpClient("SmtpServer");
emailClient.Send(message);

note that SmtpServer could be a real Smtp Server or 127.0.0.1 or "LocalHost"

hope that work
Reputation Points: 56
Solved Threads: 56
Posting Pro in Training
jbisono is offline Offline
431 posts
since May 2009
May 10th, 2009
0

Re: Contact form

First try with your gmail id to send email. The below code will guide you how you can send email using your GMAIL ID. Modify your gmail credentials from the below code:

ASP.NET Syntax (Toggle Plain Text)
  1. MailMessage mailMsg = new MailMessage();
  2. // if you want to send HTML BODY then true for plain text body then false
  3. mailMsg.IsBodyHtml = true;
  4. mailMsg.Subject = "Asp.net articles";
  5. mailMsg.Body = "<a href='http://shawpnendu.blogspot.com'>GO TO SHAWPNENDU'S BLOG</a>";
  6. mailMsg.From = new MailAddress(shawpnendu@gmail.com);
  7. mailMsg.To.Add(mxxion@yahoo.com);
  8. SmtpClient smtp = new SmtpClient("smtp.gmail.com");
  9. smtp.Credentials = new System.Net.NetworkCredential("shawpnendu@gmail.com", "password here");
  10. // If you use your smtp server then try first with blocking the below line.
  11. smtp.EnableSsl = true;
  12. smtp.Send(mailMsg);

For further details you can read:
http://shawpnendu.blogspot.com/2009/...-aspnet-c.html
Reputation Points: 26
Solved Threads: 44
Posting Whiz in Training
mail2saion is offline Offline
247 posts
since Apr 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: how to edit detailsview
Next Thread in ASP.NET Forum Timeline: Filter cascading dropdown lists





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC