惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Engineering at Meta
Engineering at Meta
G
Google Developers Blog
WordPress大学
WordPress大学
M
MIT News - Artificial intelligence
D
DataBreaches.Net
云风的 BLOG
云风的 BLOG
爱范儿
爱范儿
Microsoft Security Blog
Microsoft Security Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Blog — PlanetScale
Blog — PlanetScale
T
Tailwind CSS Blog
S
SegmentFault 最新的问题
阮一峰的网络日志
阮一峰的网络日志
博客园 - 三生石上(FineUI控件)
酷 壳 – CoolShell
酷 壳 – CoolShell
Recent Announcements
Recent Announcements
T
The Blog of Author Tim Ferriss
I
InfoQ
MyScale Blog
MyScale Blog
V
V2EX
B
Blog
罗磊的独立博客
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - speshow

初涉SQL Server性能问题(4/4):列出最耗资源的会话 初涉SQL Server性能问题(3/4):列出阻塞的会话 初涉SQL Server性能问题(2/4):列出等待资源的会话 初涉SQL Server性能问题(1/4):服务器概况 分享 大型网站的架构设计问题--大型高并发高负载网站的系统架构 Android应用程序运行机制解析 js 小小jquery等比例缩放图片效果 - speshow - 博客园 C#实现汉字转换为拼音缩写的代码 .net 导出海量数据到execl文件 - speshow - 博客园 IIs6+Rewrite+asp+php5+mysql5 .net 生成二级域名 用VSTS进行网站压力测试 各种JAVASCRIPT技巧 使用ASP.NET画饼状图 - speshow - 博客园 我们到底为了什么钻研技术? 生成图片水印 aspnetpager 分页 Jquery 服务器回调为select填值
.net 发送手机短信息
speshow · 2010-07-20 · via 博客园 - speshow

 最近开发项目中要用到发送短信功能,看了一下短信接口,由于是web开发, 选择了接口中的com的api !

当然先要引用接口中的empp.dll文件,需要注册

然后实现下面代码    

/// <summary>
///短信发送类
/// </summary>
public class SMS:DB
{
  /// <summary>
  /// 发送手机短信
  /// </summary>
  /// <param name="nRecordCount">手机号码,多个手机号用|隔开,并以|结尾</param>
  /// <param name="nOrder">短信内容</param>
  public static void SendSMS(string mobiles,string contents)
  {
    //短信服务器IP
    string host = "211.136.163.68";
    //短信服务器端口
    int port = 9981;

    //发送账户
    string accountId = "";
    string serviceId = "0";
    //发送账户密码
    string password = "";
    EMPPLib.emptcl empp = new EMPPLib.emptclClass();

    EMPPLib.ConnectResultEnum result = ConnectResultEnum.CONNECT_OTHER_ERROR;
    result = empp.connect(host, port, accountId, password);

    String msg = contents;
    EMPPLib.ShortMessage shortMsg = new EMPPLib.ShortMessageClass();
    shortMsg.srcID = accountId;
    shortMsg.ServiceID = serviceId;
    shortMsg.needStatus = true;
    EMPPLib.Mobiles mobs = new EMPPLib.MobilesClass();
    if (mobiles.IndexOf("|") > -1)
    {
      char[] cut = new char[] { '|'};
      for (Int32 i = 0; i < mobiles.Split(cut).Length-1; i++) {
        mobs.Add(mobiles.Split(cut)[i].ToString());
      }
    }
    else
    {
      mobs.Add(mobiles);
    }
    shortMsg.DestMobiles = mobs;
    shortMsg.content = msg;
    shortMsg.SendNow = true;

    empp.needStatus = true;
    if (empp != null && empp.connected == true)
    {
      empp.submit(shortMsg);
    }
  }