C # code for texting on a "web-built" platform

Source: Internet
Author: User

have been using this platform to send mobile phone messages, today to do new projects when used, but up to the blog search, had to turn over the previous source code for a long time to find, first write down, to make standby:


Using System;
Using System.Collections.Generic;
Using System.IO;
Using System.Linq;
Using System.Net;
Using System.Text;
Using System.Web;

Namespace Niunan.CardShop.Web.Code
{
public class Sendmobile
{

<summary> return status instructions for sending SMS
///
</summary>
<param name= "str" ></param>
<returns></returns>
public static string Getmobilemsmstatus (String str)
{
string s = "";
Switch (STR)
{
Case "-1":
s = "No such user account";
Break
Case "-2":
s = "key is incorrect (not user password)";
Break
Case "-3":
s = "Insufficient number of SMS";
Break
Case "-11":
s = "The user is disabled";
Break
Case "-14":
s = "Illegal characters appear in SMS Content";
Break
Case "-4":
s = "Phone number format is incorrect";
Break
Case "-41":
s = "mobile phone number is empty";
Break
Case "-42":
s = "SMS content is empty";
Break
Default
s = "Send successfully" + str + "text message";
Break
}
return s;
}
<summary> Send SMS
///
</summary>
<param name= "mobile" > Mobile phone number, multiple mobile phone number, number separated by </param>
<param name= "Body" > SMS Content </param>
public static string Sendmobilemsm (string mobile, string body)
{

String url = "http://utf8.sms.webchinese.cn/?Uid=xxxxxx&Key=xxxxxx&smsMob=" + Mobile + "&smstext=" + body;
String targeturl = URL. Trim (). ToString ();
Try
{
HttpWebRequest hr = (HttpWebRequest) webrequest.create (TargetUrl);
hr. useragent = "mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) ";
hr. Method = "GET";
hr. Timeout = 30 * 60 * 1000;
WebResponse hs = hr. GetResponse ();
Stream sr = HS. GetResponseStream ();
StreamReader ser = new StreamReader (SR, Encoding.default);
Return Getmobilemsmstatus (Ser. ReadToEnd ());
}
catch (Exception ex)
{
Throw ex;
}
}
}
}

C # code for texting on a "web-built" platform

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.