且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

C#应用程序通过PC向其他手机发送短信

更新时间:2022-11-26 16:23:16

检查您的速度:460800似乎太高了.在此处 [
Check your speed: 460800 seems too high. There is a tutorial here[^] that suggests 230400 or less. What did you use in Hyperterminal?


这就是我的方法.
This is how I did it.
e = new SerialPort("COM4", 9600, Parity.None, 8, StopBits.One);
e.Handshake = Handshake.RequestToSend;
e.WriteLine("AT+CMGF=1"+Environment.NewLine);
e.WriteLine("AT+CMGS" + "phone number here" + Environment.NewLine);
w.WriteLine("Message here"+(char)26+Environment.NewLine);



上面的代码可能包含一些小错误,因为我只是手工编写的.
如果我有更多要发送的号码,则每次发送短信时都必须关闭端口并打开.
我还没有研究为什么会发生这种情况.我的应用程序仍在开发中.

我相信您的问题可能是换行命令,我尝试使用"\ n","\ t \ n"等其他命令.
在我使用Environment.NewLine之前,什么都没做.

希望这会有所帮助.



The code above might contain some minor errors because i just wrote it by hand.
If i have more numbers to send to I have to close the port and open for each time I send a text message.
I havent looked into why it happens yet.My application is still being developed.

I believe your problem could be the newline command, I tried different commands using "\n","\t\n" and so on.
Nothing worked until i used Environment.NewLine.

Hope this helps.