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)
{
if (textboxRecipient.Text == "")
{
textboxError.Text += "Recipient(s) field must not be empty!\n";
textboxError.Visible = true;
return;
}
string ozSURL = "http://127.0.0.1";
string ozSPort = "9501";
string ozUser = HttpUtility.UrlEncode("admin");
string ozPassw = HttpUtility.UrlEncode("abc123");
string ozMessageType = "SMS:TEXT";
string ozRecipients = HttpUtility.UrlEncode(textboxRecipient.Text);
will get the message
string ozMessageData = HttpUtility.UrlEncode(textboxMessage.Text);
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
{
HTTP connection
HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(createdURL);
HttpWebResponse myResp = (HttpWebResponse)myReq.GetResponse();
System.IO.StreamReader respStreamReader = new System.IO.StreamReader(myResp.GetResponseStream());
string responseString = respStreamReader.ReadToEnd();
respStreamReader.Close();
myResp.Close();
textboxError.Text = responseString;
textboxError.Visible = true;
}
catch (Exception)
{
textboxError.Text = "Ozeki NG SMS Gateway Server is not running!";
textboxError.Visible = true;
}
}