通过ASP.Net中的GSM调制解调器发送短信 [英] Sending SMS via GSM modem in ASP.Net

查看:94
本文介绍了通过ASP.Net中的GSM调制解调器发送短信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要开发一个Web应用程序,以编程方式通过GSM调制解调器将消息发送到手机.我尝试使用GsmComm函数遇到消息服务错误500.该方法与普通c#表单应用程序相同或不同请提出正确的方法.

I need to develop a web application which sends messages to mobile phones via GSM modem programmatically.I tried using the GsmComm functions i am encountering Message Service Error 500.Is the way of approach is the same as normal c# form application or different.Please suggest the correct way.

推荐答案

public void SendSMS(string phoneNo, string message)
        {
            System.IO.Ports.SerialPort port = new System.IO.Ports.SerialPort("COM13", 115200, System.IO.Ports.Parity.None, 8, System.IO.Ports.StopBits.One);
            try
            {
                port.Open();
                port.Write("AT\r\n");
                System.Threading.Thread.Sleep(1000);
                port.WriteLine("AT+CMGF=1\r\n");
                System.Threading.Thread.Sleep(1000);
                //port.WriteLine("AT+CMGS=\"+60121212121\"\r\n");
                port.WriteLine("AT+CMGS=\"" + phoneNo + "\"\r\n");
                System.Threading.Thread.Sleep(1000);
                //port.WriteLine("Testing SMS\r\n" + '\x001a');
                port.WriteLine(message + "\r\n" + '\x001a');
                return true;
            }
            catch
            {
                return false;
            }
            finally
            {
                port.Close();
            }
        }


这篇关于通过ASP.Net中的GSM调制解调器发送短信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆