Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hai,

I am in problem.. Here is my code.
C#
MailMessage mail = new MailMessage(Mail.Text, "enquiry@domain.com", Subject.Text, Statement.Text);
SmtpClient SMTPServer = new SmtpClient();
SMTPServer.Host = "smtpout.secureserver.net";
SMTPServer.Port = 465;
SMTPServer.EnableSsl = true;
SMTPServer.Credentials = new System.Net.NetworkCredential("username", "psw");
SMTPServer.Send(mail);
Posted
Updated 7-Aug-12 7:15am
v2
Comments
ZurdoDev 7-Aug-12 12:12pm    
Sounds like you need to make sure your connecting properly.
Member 9327701 7-Aug-12 12:14pm    
can you give detailed information
ZurdoDev 7-Aug-12 12:23pm    
No. You are passing the basic stuff, that is host, port, and credentials but you'll have to get with whoever manages the SMTP server that you are trying to connect to and figure out what part is missing.

Looks like some issue with your implementation.

Have a look at this Microsoft Video tutorial:
Use ASP.NET to send Email from Website[^]
Tutorials on sending Email in ASP.NET[^]

Have a look at this tip too: Sending an Email in C# with or without attachments: generic routine.[^]
 
Share this answer
 
Just be sure these 2 lines are proper:

SMTPServer.Port = 25;
SMTPServer.EnableSsl = false;

Some times it sending the response and due to security reasons it is unable to send the mail.
 
Share this answer
 
C#
MailMessage mail = new MailMessage(Mail.Text, "enquiry@domain.com", Subject.Text, Statement.Text);
SmtpClient SMTPServer = new SmtpClient();
SMTPServer.Host = "smtpout.secureserver.net";
SMTPServer.Port = 465;
SMTPServer.EnableSsl = true;
SMTPServer.Credentials = new System.Net.NetworkCredential("username", "psw");

SMTPServer.ServicePoint.MaxIdleTime = 1; /* this code prevent your message from terminated */

SMTPServer.Send(mail);
 
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