如何使用C Sharp从窗口应用程序项目发送短信

如何使用C Sharp从窗口应用程序项目发送短信

问题描述:

尊敬的会员
代码项目.

子:-如何使用C Sharp向手机发送短信.

尊敬的先生,
我想通过c窗口应用程序项目向移动电话发送短信,我有DLL,但我希望其代码意味着如何制作用于发送SMS的DLL. 如果任何人有代码或任何信息,请通知我.

谢谢.
Akhilesh

Dear Member
Code Project.

Sub:-How to send SMS to mobile no using c sharp.

Respected sir,
i want to send fress sms through c sharp window application project to mobile no.i have DLL,but i want its code means how to make DLL for sending SMS.
if any one have code or any information please inform me.

Thank you.
Akhilesh

嗨Akhilesh,
我知道如何从普通的GSM调制解调器发送消息.

为此,您需要一个称为GSM MODEM的硬件设备和一个普通的SIM(基于您选择的Netwrok运营商的SMS费用);
之后,将其连接到您的电脑
并转到Visual Studio,然后如果需要dll文件,则创建一个新项目或类类型.

然后按照以下代码行

包括类库system.io.ports;

然后,创建一个串行端口类对象

SerialPort sp =新的SerialPort();
sp.Name ="COM1";//明智地选择端口
sp.baudrate = 9600;
sp.parity = none;
//根据您的要求更改串口坐标..

//现在配置完串行端口后,必须先打开它,然后才能与调制解调器通信

sp.Open();//这是一种在.net中打开串行端口的方法(请记住,使用此语句时仅COM1端口会打开.


其中textbox1是您的消息
sp.Write("AT + CMGS = \"; + 91"+ textBox1.Text +" \" + Environment.NewLine);
Thread.Sleep(2000);
sp.Write(textBox2.Text +(char)26 + Environment.NewLine);
MessageBox.Show(消息已安全发送");

*****这会发送一条消息******

您甚至可以通过短信网关发送消息.
试试Google吧!
Hi Akhilesh,
I Knew how to send messages from a normal GSM modem.

For that You need a Hardware device called GSM MODEM and a normal SIM(SMS cost based on Netwrok operator you choose);
After that connect it to your pc
and go to visual studio and then create a new project or class type if you need dll file.

then follow these code lines

include the class library system.io.ports;

then,create a serial port class object

SerialPort sp=new SerialPort();
sp.Name="COM1";//choose your port wisely
sp.baudrate=9600;
sp.parity=none;
//change the serial port coordinates with your requirements..

//Now after configuring the serial port you must have to open it before the communication with the modem

sp.Open();//it''s a method to open the serial port in .net(remember only the port COM1 will open when you use this statement.


where textbox1 is your message
sp.Write("AT+CMGS=\";+91" + textBox1.Text + "\"" + Environment.NewLine);
Thread.Sleep(2000);
sp.Write(textBox2.Text + (char)26 + Environment.NewLine);
MessageBox.Show("Message sent seccuessfully");

*****this sends a message******

You can even send messages through SMS GATEWAYS.
Try Google it!!