Contact form

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Dec 2008
Posts: 37
Reputation: kischi is an unknown quantity at this point 
Solved Threads: 0
kischi kischi is offline Offline
Light Poster

Contact form

 
0
  #1
May 7th, 2009
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:

  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
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 185
Reputation: jbisono is an unknown quantity at this point 
Solved Threads: 23
jbisono's Avatar
jbisono jbisono is offline Offline
Junior Poster

Re: Contact form

 
0
  #2
May 7th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 217
Reputation: mail2saion is an unknown quantity at this point 
Solved Threads: 31
mail2saion's Avatar
mail2saion mail2saion is offline Offline
Posting Whiz in Training

Re: Contact form

 
0
  #3
May 10th, 2009
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:

  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
MARK AS SOLVED if its help you.

REGARDS
MCTS - Shawpnendu bikash maloroy
http://shawpnendu.blogspot.com
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC