Reputation: 85
I have an mail server installed for intranet mailing in my office. I have been using Windows live and outlook express for accessing emails on client machines. I am planning to build a reporting application in c# winforms in which certain reports has to be created and it should be sent through email for all the users. Reports should be generated and sent by any of the client systems. For mailing purpose I have done the following.
MailMessage message = new MailMessage();
SmtpClient smtp = new SmtpClient("192.168.0.113",25);
message.From = new MailAddress("[email protected]");
message.To.Add(new MailAddress("[email protected]"));
message.Subject = "Test";
message.Body = "Content";
smtp.EnableSsl = true;
smtp.UseDefaultCredentials = false;
smtp.Credentials = new System.Net.NetworkCredential("[email protected]", "123456");
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.Send(message);
domain name has been changed.192.168.0.113 is smtp host.same seetings are given in outlook express and windows live.user credentials are correct but application is throwing the follwing SMTP exception.
An unhandled exception of type 'System.Net.Mail.SmtpException' occurred in System.dll InnerException: System.Net.Sockets.SocketException HResult=-2147467259 Message=No connection could be made because the target machine actively refused it 192.168.0.113:25 Source=System ErrorCode=10061 NativeErrorCode=10061 StackTrace: at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) InnerException:
This is what I have got.. any idea about this? it says machine actively refused. what could be wrong?? please suggest..
Upvotes: 0
Views: 233
Reputation: 675
Check your antivirus. I have faced this issue long time ago.
Upvotes: 0
Reputation: 4792
You have to use smtp.gmail.com in
SmtpClient smtp = new SmtpClient("192.168.0.113",25);
like
SmtpClient smtp = new SmtpClient("smtp.gmail.com",25);
If your host is gmail.
Find your host here
https://www.arclab.com/en/kb/email/list-of-smtp-and-pop3-servers-mailserver-list.html
Upvotes: 0