如何从asp.net webapplication发送短信 [英] How to send a SMS from asp.net webapplication
本文介绍了如何从asp.net webapplication发送短信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default9.aspx.cs" Inherits="Default9" %>
<%@ Import Namespace='System.Text' %>
<%@ Import Namespace='System.IO' %>
<%@ Import Namespace='System.Net' %>
<%@ Import Namespace='System.Web' %>
<%@ Import Namespace='System.Web.UI' %>
<%@ Import Namespace='System.Web.Services' %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
public void SendSMS()
{
UriBuilder urlBuilder = new UriBuilder();
urlBuilder.Host = "127.0.0.1";
urlBuilder.Port = 8800;
string PhoneNumber = "+9154672585784";
string message = "Just a simple text";
urlBuilder.Query = string.Format("PhoneNumber=%2B" + PhoneNumber + "&Text=" + message);
HttpWebRequest httpReq = (HttpWebRequest)WebRequest.Create(new Uri(urlBuilder.ToString(), false));
HttpWebResponse httpResponse = (HttpWebResponse)(httpReq.GetResponse());
}
protected void Page_Load(object sender, EventArgs e)
{
SendSMS();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Send SMS</title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
它显示异常..无法连接远程服务器...所以我做什么..请帮助我....
it shows an exception..unable to connect the remote server...so what i do..please help me....
推荐答案
我没有提供用户名和发件人ID b'coz你必须从短信卖家购买短信然后你会得到这个东西,授权号码是获取短信发送报告的号码
拿走所有手机你不想在数据表中发送短信作为dt
I Have not Provided the UserName And sender ID b'coz u have to purchase sms from sms Seller then u will get this thing and authorized number is the number to get report of sms send
take all the mobile no u want to send sms in datatable as dt
for(int i=0;i<dt.rows.count;i++)>
{
string url1 = "http://api.mVaayoo.com/mvaayooapi/MessageCompose?user=User_Name&senderID=ID SMS&receipientno=" + dt.Rows[i][0].ToString() + "&msgtxt='"+TextBoxName.Text+"' API&state=4";
WebRequest request = HttpWebRequest.Create(url1);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream s = (Stream)response.GetResponseStream();
StreamReader readStream = new StreamReader(s);
string dataString = readStream.ReadToEnd();
response.Close();
s.Close();
readStream.Close();
}
这适用于我的asp。 net with c#web application希望你的查询解决
this works in my asp.net with c# web application hope ur query is solve
这篇关于如何从asp.net webapplication发送短信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文