发送短信

来源:互联网 发布:福建11选5遗漏数据查询 编辑:程序博客网 时间:2024/05/16 07:25

1.短信格式:您名下的学生:学生名字 编号:123,2017/01/01在留学管家修改了邮箱地址,原邮箱为:sun@xx.com 新邮箱为:sun@xx.com&typeid=1

 string postdata = string.Format("mobile={0}&content=您名下的学生:{1} 编号:{2},{3}在留学管家修改了邮箱地址,原邮箱为:{4} 新邮箱为:{5}&typeid=1", item.AdviserMobile, stuName, stuNo, DateTime.Now.ToString("yyyy-MM-dd"), email, value.Field);                                string result1 = JsonHelper.PushToWeb("http://xxxx:10086/SMSPush", postdata);                                //192.168.0.120

2.对应的pushtoweb方法

   public static string PushToWeb(string weburl, string data)        {            byte[] byteArray = Encoding.UTF8.GetBytes(data);            HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(new Uri(weburl));            webRequest.Method = "POST";            webRequest.ContentType = "application/x-www-form-urlencoded";            webRequest.ContentLength = byteArray.Length;            Stream newStream = webRequest.GetRequestStream();            newStream.Write(byteArray, 0, byteArray.Length);            newStream.Close();            //接收返回信息:            HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse();            StreamReader aspx = new StreamReader(response.GetResponseStream(), Encoding.UTF8);            return aspx.ReadToEnd();        }
0 0
原创粉丝点击