Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Nov 21, 2012 11:00 AM by bbcompent1
Nov 19, 2012 07:12 PM|LINK
I tried the following code to send emails from my web application.
We use Lotus notes as a email application.
MailMessage message = new MailMessage();
message.Subject = "Your account details";
message.From = new MailAddress("email@example.com");
message.Body = "Bonjour";
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("myclient.com");
catch (Exception ex)
I received the following error message:
Failure sending mail.
Nov 19, 2012 07:24 PM|LINK
What error are you getting? If its a 550, you have to see your lotus notes admin to have SMTP relaying turned on.
Nov 19, 2012 07:40 PM|LINK
Thanks for your response.
I have received:
Nov 19, 2012 07:47 PM|LINK
Ok, rewrite your catch to be like this:
catch (Exception ex)
That will show what the error really is.
Nov 19, 2012 07:59 PM|LINK
Thanks for your suggestion.
I never cared knowing more about the error messages.
Looks like there is a lot to learn from it.
Here is the complete error message.
System.Net.Mail.SmtpException: Failure sending mail.
---> System.Net.WebException: Unable to connect to the remote server
---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 126.96.36.199:25
Nov 19, 2012 08:03 PM|LINK
Ok, that means that SMTP may not be enabled on your email server. I would show this error to your administrators as they could troubleshoot the problem. If memory serves me correctly, most email servers have SMTP relaying disabled. You have to turn it on
intentionally and allow certain machines.
Nov 19, 2012 08:29 PM|LINK
Thanks for your suggestions.
Reaching my administrator is a tough task and it takes long time (usually weeks).
But I will give it a shot.
I am not sure if the smtp server that coded is correct though, can you please tell me a way to find out my SMTP Server?
Nov 20, 2012 01:25 PM|LINK
Unfortunately, I have no way of knowing what your SMTP server would be, your IT staff can provide that to you however.
Nov 20, 2012 09:41 PM|LINK
I do not know about Lotus but for win server's SMTP
At web config..
<network host="(your server name)" port="25" userName="(id)" password="(password)"/>
Nov 21, 2012 11:00 AM|LINK
What you're seeing here is best practice. We want to modify settings in the web.config file, not have to hard-code variables throughout the application. That's why we put SQL connection strings and mail settings inside the web config. That way we don't re-write
our code just to change a setting.