0

I have to send a mail on form submit but it does'nt work with me

            // envoyer mail
            SmtpClient client = new SmtpClient("host");
            //User name and password goes here 


            MailMessage mailMessage = new MailMessage { From = new MailAddress("someone@somewhere.com") };
            mailMessage.To.Add("someone@somewhere.com");
            mailMessage.Subject = "Hello There";
            mailMessage.Body = "Hello my friend!";

            client.Host = "host";
            client.Port = 25;
            User name and password
            client.EnableSsl = false;
            client.Send(mailMessage);

Thank you

Basanta Matia
  • 1,504
  • 3
  • 15
  • 27
oumaima
  • 71
  • 9
  • 1
    Give some more information. What is happening? Any raised exception? Any error? – Sid Apr 06 '17 at 13:02
  • NO errors just form succefully submitted and nothing else – oumaima Apr 06 '17 at 13:03
  • [Try this solution](http://stackoverflow.com/questions/704636/sending-email-through-gmail-smtp-server-with-c-sharp) – M. Adeel Khalid Apr 06 '17 at 13:04
  • @oumaima: What's the response from the SMTP server? It's possible that the code is successfully sending an email but the problem is somewhere between the SMTP server and your inbox. – David Apr 06 '17 at 13:06
  • are you sure you set up 'host' properly? Why don't you use 'localhost' and see if you can receive email locally? PaperCut is good appliation for catching localhost emails – jkl Apr 06 '17 at 13:06
  • @jkl with localhost there is A first chance exception of type 'System.Net.Mail.SmtpException' occurred in System.dll – oumaima Apr 06 '17 at 13:15
  • @oumaima: Well, an exception would explain why the email isn't being sent... – David Apr 06 '17 at 13:18
  • @MAdeelKhalid thank you.. it works for me now :) – oumaima Apr 06 '17 at 13:37

0 Answers0