Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
how to sent msg pc to mobile in asp.net
Posted 22-Jan-12 21:30pm
Comments
Member 9954718 at 18-Apr-13 1:06am
   
Getting exception and it displays "Ozeki NG SMS Gateway Server is not running!"
Member 10278776 at 2-Oct-13 3:20am
   
error this code Unable to connect to the remote server plz help me ....
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

see this article that explians
sms sending by Using a GSM modem
Sending SMS using .NET
 
or use SMS_gateway
Sending-SMS-using-NET-through-a-Web-service
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Hi,
Try this;
smssend.aspx
<form id="smsdata" runat="server">
    <asp:Table id="smstable" runat="server" style="text-align:left; border-width:thin;
      border-color:Silver;" BorderStyle="Solid">
        <asp:TableRow>
            <asp:TableCell ColumnSpan="2">
                 <b>Compose a message:</b>
                 <br />
                 <br />
            </asp:TableCell>
        </asp:TableRow>
        <asp:TableRow>
            <asp:TableCell HorizontalAlign="Left" VerticalAlign="Top">
                 <asp:Label ID="labelRecipient" runat="server" Text="Recipient: ">
                 </asp:Label>
            </asp:TableCell>
            <asp:TableCell>
                 <asp:TextBox ID="textboxRecipient" runat="server">
                 </asp:TextBox>
            </asp:TableCell>
        </asp:TableRow>
        <asp:TableRow>
            <asp:TableCell HorizontalAlign="Left" VerticalAlign="Top">
                 <asp:Label ID="labelMessage" runat="server" Text="Message Text: ">
                 </asp:Label>
        </asp:TableCell>
            <asp:TableCell>
                 <asp:TextBox ID="textboxMessage" runat="server" TextMode="MultiLine">
                 </asp:TextBox>
            </asp:TableCell>
        </asp:TableRow>
        <asp:TableRow>
            <asp:TableCell ColumnSpan="2" HorizontalAlign="Center">
                <asp:Button ID="buttonSend" runat="server" Text="Send Message"
                  OnClick="buttonSendOnClick" />
            </asp:TableCell>
        </asp:TableRow>
        <asp:TableRow>
            <asp:TableCell ColumnSpan="2" HorizontalAlign="Center">
                <asp:TextBox ID="textboxError" runat="server" BorderStyle="None"
                  TextMode="MultiLine"></asp:TextBox>
            </asp:TableCell>
        </asp:TableRow>
    </asp:Table>
</form>
smssend.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
    textboxRecipient.Width = 400;
    textboxMessage.Width = 450;
    textboxMessage.Rows = 10;
    textboxError.Width = 400;
    textboxError.Rows = 5;
 
    textboxError.ForeColor = System.Drawing.Color.Red;
    textboxError.Visible = false;
    textboxError.Text = "";
 
    if (!Page.IsPostBack)
    {
        textboxRecipient.Text = "+441234567";
        textboxMessage.Text = "Hello World!";
    }
}
smssend.aspx.cs
protected void buttonSendOnClick(object sender, EventArgs e)
{
    //fields are required to be filled in:
    if (textboxRecipient.Text == "")
    {
        textboxError.Text += "Recipient(s) field must not be empty!\n";
        textboxError.Visible = true;
        return;
    }
 
    //we are creating the necessary URL string:
    string ozSURL = "http://127.0.0.1"; //where Ozeki NG SMS Gateway is running
    string ozSPort = "9501"; //port number where Ozeki NG SMS Gateway is listening
    string ozUser = HttpUtility.UrlEncode("admin"); //username for successful login
    string ozPassw = HttpUtility.UrlEncode("abc123"); //user's password
    string ozMessageType = "SMS:TEXT"; //type of message
    string ozRecipients = HttpUtility.UrlEncode(textboxRecipient.Text); //who
    will get the message
    string ozMessageData = HttpUtility.UrlEncode(textboxMessage.Text); //body
    of message
 
    string createdURL = ozSURL + ":" + ozSPort + "/httpapi" +
        "?action=sendMessage" +
        "&username=" + ozUser +
        "&password=" + ozPassw +
        "&messageType=" + ozMessageType +
        "&recipient=" + ozRecipients +
        "&messageData=" + ozMessageData;
    ...
}
smssend.aspx.cs
protected void buttonSendOnClick(object sender, EventArgs e)
{
...
    try
    {
        //Create the request and send data to Ozeki NG SMS Gateway Server by
        HTTP connection
        HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(createdURL);
 
        //Get response from Ozeki NG SMS Gateway Server and read the answer
        HttpWebResponse myResp = (HttpWebResponse)myReq.GetResponse();
        System.IO.StreamReader respStreamReader = new System.IO.StreamReader(myResp.GetResponseStream());
        string responseString = respStreamReader.ReadToEnd();
        respStreamReader.Close();
        myResp.Close();
 
        //inform the user
        textboxError.Text = responseString;
        textboxError.Visible = true;
    }
    catch (Exception)
    {
        //if sending request or getting response is not successful, Ozeki NG - SMS Gateway Server may not be running
        textboxError.Text = "Ozeki NG SMS Gateway Server is not running!";
        textboxError.Visible = true;
    }
}
  Permalink  
v2
Comments
sariana at 23-Jan-12 4:08am
   
My +5
srmohanr at 20-Dec-13 4:14am
   
Hi,
I have tried this, but this is showing me an error 'Unable to connect to the remote server'.
Please help
Kishanthakur at 23-Jan-12 5:13am
   
thanks a lot mate
pashad at 23-Jan-12 8:08am
   
you are welcome
onurag19 at 6-Mar-13 14:17pm
   
Its showing Ozeki NG Sms Gateway not working
suryaVenkat at 16-Jan-14 8:11am
   
i also tried this.. not working.. it shows the same error "unable to connect to the remote server"
Member 10639329 at 13-May-14 1:04am
   
Its showing Ozeki NG Sms Gateway not working

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web03 | 2.8.140709.1 | Last Updated 5 Jul 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid