You may use 3rd party libraries to do the task.
See this article:
How To Send and Receive SMS using GSM Modem[
^]
Using 3rd party libraries will make your task very easy.
But you may also choose to write your own code. Consider the guidelines below:
Modems(in your case mobile) understands AT commands. So you need to learn AT commands first. Refer:
Introduction to AT commands[
^]
After you have studied AT commands,
There are few steps you need to perform in order to send AT commands to mobile using C#
1)Configure and open the serial port using using System.IO.Ports class
-
SerialPort.Open()
and
SerialPort.Close()
API are available for doing the same.
2)Write the AT command to opened COM port in step 1.
Serialport.Writeline()
API can be used for same.
Example code is pasted for doing same:
private SerialPort portConfig = new SerialPort();
portConfig.PortName = COM4 ;
.....
.....
portConfig.Open();
portConfig.WriteLine("ATD" + mobileNumber + ";");
Read the below article. It doesn't use any 3rd party library for sending/receiving sms using gsm modem.
Send and Read SMS through GSM Modem using AT Commands[
^]
Hope it helps. If you still have issues get back.
Finally a suggestion: This question has been asked so many times in the forum. Please do search once before you ask.