Click here to Skip to main content
15,905,913 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
UriBuilder urlBuilder = new UriBuilder();
        urlBuilder.Host = "127.0.0.1";
        urlBuilder.Port = 8800;

        //string PhoneNumber = "60123456789"; 
        string PhoneNumber = "09638136263";
        string message = "Just a simple text";

        urlBuilder.Query = string.Format("PhoneNumber=%2B" + PhoneNumber + "&Text=" + message);

        HttpWebRequest httpReq = (HttpWebRequest)WebRequest.Create(new Uri(urlBuilder.ToString(), true));
        HttpWebResponse httpResponse = (HttpWebResponse)(httpReq.GetResponse());
       Response.Write(httpResponse.StatusCode.ToString());
        Response.Write("sms send successfully"); 


Error is : Unable to connect to the remote Server in above bold line.
Posted
Updated 2-Jul-12 0:44am
v2

Usually means that the tcp port you are trying to connect to does not have any service listening on it, i.e. it is closed and a tcp connection could not be made, let alone a SMTP connection. Nothing will show in your exchange logs as it is failing at a lower level in the network stack and your mail server will not even see the connection attempt.

f you are using any antivirus software check it's log to see whether it is because of the antivirus. I faced same problem when McAffee was blocking my mails (there is a security policy - Prevent mass mailing worms from sending mails). Edit this policy and add your application to the exception list. In my case this sorted the problem. Please check if it works for you.
 
Share this answer
 
It can be because of various reasons. You need to look at them one by one.
Is the port open? Firewall permissions in place?

Further make sure you have configured SMTP configuration in Web.Config:
<system.net>
   <mailSettings>
     <smtp from="abc@somedomain.com">
       <network host="somesmtpserver" port="25" userName="name" password="pass" defaultCredentials="true" />
     </smtp>
   </mailSettings>
</system.net>


If needed, have a look at this Microsoft Video tutorial:
Video: Use ASP.NET to send Email from Website[^]
 
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