在Winform中发送短信的问题 [英] Problem sending sms message in winform
问题描述
我正在尝试开发一个WinForm应用程序,该应用程序允许我通过串行端口发送短信.我将来自蓝牙的蓝牙连接到串行端口COM7.
串行端口是开放的现在,我只需要找到一种通过开放端口发送消息的方法.我正在使用的代码处于起步阶段,就像这样
I am trying to develop a WinForm Application that will allow me to send sms message via a serial port. I have bluetooth from samsung gravity tieing into serial port COM7.
The serial port is open Now I only have to find a way to send the message via the open port. The code that i am using which is in the beginning stages looks like this
private SerialPort port;
private string designatedSerialPortNumber;
private string outgoingNumber;
private bool errorOccured;
public Form1()
{
InitializeComponent();
port.ErrorReceived += new SerialErrorReceivedEventHandler(port_ErrorReceived);
}
void port_ErrorReceived(object sender, SerialErrorReceivedEventArgs e)
{
errorOccured = true;
}
private void button1_Click(object sender, EventArgs e)
{
outgoingNumber = recepientNumber.Text;
designatedSerialPortNumber = "COM" + PortNumber.Text;
port = new SerialPort(designatedSerialPortNumber, 9600, Parity.None);
port.DataBits = 8;
port.StopBits = StopBits.One;
port.RtsEnable = true;
port.DtrEnable = true;
port.NewLine = System.Environment.NewLine;
port.Open();
if (IsOpen() && !errorOccured)
{
// port opens and no error was thrown using COM7
// samsung mobile request permission to serial connect
}
port.Close();
}
private bool IsOpen()
{
return port.IsOpen;
}
如果有人看到了任何很好的示例,可以为我指出从串行端口发送短信的信息,或者您可以给我一些指示或建议,将不胜感激.
If anyone has seen any good examples that they can point me to on sending sms from serial port or if you may be able to give me a few pointers or suggestions it would be greatly appreciated.
推荐答案
Google:Wonderfull工具.我喂了你的主题,然后按了搜索"
第一个链接:您的问题.
第二个链接:这个问题 [ ^ ].
现在,你为什么不能这样做?
我已提取相关行:
Google: Wonderfull tool. I fed it your subject and pressed "Search"
First link: Your question.
Second link: This question[^].
Now, why couldn''t you do that?
I have extracted the relevant lines:
string mobile_number = "+88XXXXXXXXXXX";
string message = "Hi";
port.WriteLine("AT+CMGS=" + mobile_number + "\r" + message + (char)(26));
您尝试查看是否可行,因为我已经执行了搜索,发现该链接无法获取该代码好好工作.如果您找到了使之工作的方法,请告诉我?
Did you try to see if that works because ive already performed that search found that link could not get that code to work properly. If you have found a way to make that work please let me know?
这篇关于在Winform中发送短信的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!