Dear reader, today we will discuss a very important topic, sending SMS alerts to a mobile phone that is a common demand of most clients. I have experience developing donation collection software. In that software we used a GSM Modem to send a SMS thanks to the donor. So we developed a small application that runs on the server and sends a SMS whenever a new record is inserted into the database from any client.
In this application we will use the following:
- GSM Modem (I have used Vodafone; you can use any)
- SIM Card.

Step 1
Create the table in SQL Server.
CREATE TABLE [dbo].[Donor_Profile](
[Don_Date] [datetime] NULL,
[Don_Donor_ID] [varchar](20) NOT NULL,
[Don_Donor_Name] [varchar](50) NULL,
[Don_Mobile_Phone] [varchar](50) NULL,
[Don_Member] [varchar](10) NULL,
[Don_SMS1] [varchar](10) NULL,
[Don_SMS2] [varchar](10) NULL,
[Don_Logo] [image] NULL,
[Don_Donor_Type] [int] NULL,
CONSTRAINT [PK_Donor_Profile] PRIMARY KEY CLUSTERED
(
[Don_Donor_ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
Step 2
Now you can insert any record in the table but please make sure to insert:
[Don_Donor_ID]= CF-00001-12 and leave the [Don_SMS1], [Don_SMS2] field NULL, [Don_Mobile_Phone] please enter valid phone number where you want to receive the SMS.
Step 3
Create the new Desktop application.

Step 4
Design the form as shown in the picture.

Step 5
Dear Reader, please read this carefully in this step we need to include the following DLL files in the bin\ Debug folder:
- GSMCommServer.dll
- GSMCommShared.dll
- GSMCommunication.dll
- PDUConverter.dll
Step 6
Now we need to add the reference to the project as shown in the picture.


Step 7
Now we have added one more reference.

Step 8
Now we need to move to the code behind window and use these references in the code.

Step 9
Now we need to add few textboxes and private variables that we will use in our code.













DeveloperPosted Aug 5, 2024, 5:28 AM
GSM modem required or not
cletus igbePosted Nov 28, 2023, 2:06 PM
I followed your instructions above and code my project, it works 100%. My question now is how can we add a condition to check if message was sent successfully?
cletus igbePosted Nov 28, 2023, 2:03 PM
Thank you.
RuhulPosted Feb 2, 2021, 3:22 AM
Where is your source file ?
Zeeshan RehmatPosted Nov 17, 2020, 11:51 PM
Message send successfully but i am getting the exception e.g "No data received from phone after waiting for 25016ms."
Jorshy ChanPosted Jun 27, 2020, 10:30 AM
For texts with more than 160 characters?
Kenfack CathyPosted Apr 15, 2020, 6:21 AM
Les etapes un et deux je ne les comprends vraiment pas , enfaite je n'ai pas encore execute votre solution , jusqu'ici les questions que je vous pose sont celles que j'ai rencontre en implementant ma solution par moi mm, une fois que j'ai vu votre solution elle m'a intererser c'est pourquoi je vous pose des questions , et aussi je ne toruve pas le lien du fichier svp merci
Kenfack CathyPosted Apr 15, 2020, 6:15 AM
Mr svp ou es qu'on entre le message qu'on veut envoyer, merci.
Kenfack CathyPosted Apr 15, 2020, 6:14 AM
Mr svp j'ai vaiment besoin de vos reponses je travaille actuellement sur ce projet: application d'envoie sms partout dans le monde grace a un modem gsm en C# ceci est le projet sue lequel je travail j'ai vraiment besoin de votre aide . merci mr
Kenfack CathyPosted Apr 15, 2020, 6:12 AM
Svp j'aimeerais egalement savoir si c'est possible d'envoyer les messages partout dans le monde avec ceci.
Kenfack CathyPosted Apr 15, 2020, 6:09 AM
Salut mr svp comment choisi le port COM qui communiquera avec notre modem , la je suis perdu , quand je me rends dans les paremetres de ma machine j'ai plusieurs ports COM d'autre avec le mot in use devant je ne sais quel utilise. merci
Benjamin CerdenaPosted Jan 12, 2020, 4:13 AM
Hi! how can I download your .rar file?
Rolando MotaPosted Oct 10, 2019, 2:07 PM
Hello, do you know that it works for windows 10? I am working with BAM huawei with connection USB, but I can not detect it as port serial connection, can you help me??
raffie gollayanPosted Aug 15, 2019, 7:59 PM
An unhandled exception of type 'GsmComm.GsmCommunication.CommException' occurred in GSMCommunication.dllAdditional information: No phone connected. Can't seems to find any answer in the web please help.
shahid hussainPosted Feb 13, 2019, 9:35 PM
Can we use mobile phone instead of gsm modem??
Said HussainPosted Jan 7, 2019, 11:41 PM
Hi sir how i can send urdu sms
Zeshan RaoPosted Nov 26, 2018, 3:16 AM
Hi Sir , I want to send sms through mobile except GSM device .. Is it possible ? if possible then how ?
Dwight PerelloPosted Nov 12, 2018, 8:48 PM
Hi, I am using GSMCOmm library as well. just wondering what seems to be the problem because for whatever reason it just stop receiving text msgs. It was working fine before and I can still send sms but not receive
zahra mbeigyPosted Oct 18, 2018, 6:02 AM
Hi, Mr, Naveed, im getting this error 'Could not find file 'C:\...\bin\Debug\IPCONFG.txt'.why/
Javed IqbalPosted Oct 5, 2018, 5:28 AM
Hi, I have included GSMCommServer.dllGSMCommShared.dllGSMCommunication.dllPDUConverter.dll from Debug folder but still it cant reference to those dlls in code...
George FergusonPosted Sep 25, 2018, 5:15 PM
Thanks a lot. It really worked. Please can the senders number be changed to Name. Please this is my Email: [email protected]
Rey ManjaresPosted May 26, 2018, 5:34 AM
Hi again Mr. Naveed, I've got the issue fix already, but I have one question, does this api can handle a scenario, which will display a title/name instead of the sender's number? thank you in advance for the accommodation.
Rey ManjaresPosted May 26, 2018, 4:57 AM
Hi Mr. Naveed, Im getting this error "Message service error 500 occurred." can you please help me rectify this issue. Thank you in advance.
Sayed ShoaibPosted Mar 28, 2018, 2:46 PM
Sir I want to send SMS from c# what should I use gsm module or api which one is inexpensive and give good services.
shanigarapu rakeshPosted Feb 5, 2018, 1:22 AM
Its not working. Exception like "Message service error 500 occurred."
Prince KhanPosted Jan 29, 2018, 5:51 AM
Does'nt work its fake
Saikat MekdarPosted Nov 17, 2017, 2:14 AM
Hello sir,How to show sent and received messages into this application?
josua edwardPosted Sep 21, 2017, 11:31 PM
Hello sir, do you use any gsm module? or modem?
Salman MushtaqPosted Sep 17, 2017, 7:57 AM
Can I use my mobile phone instead of modem?
cobra TwoPosted Jun 3, 2017, 4:25 PM
Thank You it works fine
jitendra singhPosted May 2, 2017, 2:03 AM
Hi sir can i do recharge using this method on USSD ocde
Rémili AbirPosted Apr 4, 2017, 10:34 AM
At first when i connect the modem using connect button then show modem connected successfully but when i send message using send button then show modem is not available ,ansewer me and thank you
blue dovePosted Mar 5, 2017, 5:30 AM
If I want to send sms to multiple students what changes should I made in this code?
Ritesh SinghPosted Jan 30, 2017, 12:43 PM
Its working fine sir ...thanks a lot ..!!
Lahoucine JapetPosted Jan 4, 2017, 10:49 AM
I get an error when i try to connect Error message "Unable to open port COM.."
xzaq 8520Posted Dec 25, 2016, 12:40 PM
"No phone connected." Error is giving ... Please Help..
xzaq 8520Posted Dec 25, 2016, 12:39 PM
"No phone connected." Error is giving
anwar hossainPosted Jul 22, 2016, 5:23 AM
At first when i connect the modem using connect button then show modem connected successfully but when i send message using send button then show modem is not available why Please give the answer..
Zubair KatalPosted Feb 21, 2016, 6:13 AM
i'm using ptcl evo having a sim in it but it is not connecting to the application... GSM modem is not availabe exception is throwing .. what is the problem with that ..??
Ravi AgrawalPosted Feb 10, 2016, 4:05 AM
I want to use in the web application to send and receive SMS in db. Please tell me how is that possible.
Ravi AgrawalPosted Feb 10, 2016, 4:02 AM
Is it work on usb port. If not then how we can change code for USB port.
Tharuka KannangaraPosted Jan 14, 2016, 4:01 AM
how to send bulk sms using this
Yaseen UlHaqPosted Jan 3, 2016, 11:42 AM
is valid and modem connected in this senario
Yaseen UlHaqPosted Jan 3, 2016, 11:42 AM
i am using samsung gelaxy grand prime and port no 5
Yaseen UlHaqPosted Jan 3, 2016, 11:42 AM
the code is in working condition but i am facing different time different error
Yaseen UlHaqPosted Jan 3, 2016, 11:41 AM
dear port not open error
Rizwan UllahPosted Oct 23, 2015, 11:47 AM
to all those who are getting this error ""Phone not connected " or "Message not Sent"... there is a logical error in this code. if you are using a nokia phone.. then port number should be 4 or com4 and baud rate should be 112500 and timeout should be 300, AND ALWAYS CLOSE THE PORT WHEN MESSAGE IS SENT, IF PORT IS LEFT OPEN IT WONT CONNECT 2ND TIME AND WILL GIVE ERROR..
Mohammad InayatullahPosted Sep 17, 2015, 6:12 AM
Hi, I am getting the error "Text is too long. A maximum of 140 resulting octets is allowed. The current input results in 392 octets." can you please guide me.
Mohammad InayatullahPosted Sep 17, 2015, 6:12 AM
Hi, I am getting the error "Text is too long. A maximum of 140 resulting octets is allowed. The current input results in 392 octets." can you please guide me.
sona gharagyozyanPosted Aug 31, 2015, 4:58 AM
Hi, I am getting the following error "SMS not sent". But modem connected successfully. What could be the reason? Please help, Thank you.
Denes AntonioPosted May 9, 2015, 5:39 PM
how i send more than 160 character?
DarinPosted Feb 9, 2015, 5:38 AM
there is errror in the code
Sourabh SomaniPosted Feb 8, 2015, 9:14 AM
Very Nice sir
DarinPosted Feb 4, 2015, 7:03 AM
i got an error saying that the name 'code' does not exist in the current context.
Sunil SinghPosted Dec 4, 2014, 5:17 AM
Hi, I am getting the following error 'No phone is connected' and its from the following line of code: "comm.SendMessage(pdu);". Although when I connect it says 'Modem connected successfully.' Please help to rectify the error.
kawsar hmedPosted Nov 29, 2014, 5:22 AM
Hi , Can i use this project in windows 7
Ahmad -Posted Nov 26, 2014, 8:44 AM
Hi, How can I get and show delivery report?
venkadesan perumalPosted Nov 21, 2014, 4:12 AM
please check your balance
Kingsley BainnPosted Oct 31, 2014, 7:08 AM
Hi, I am getting the following error 'No phone is connected' and its from the following line of code: "comm.SendMessage(pdu);". Although when I connect it says 'Modem connected successfully.' I need your help asap.
Vi Lâm TrươngPosted Sep 28, 2014, 9:43 PM
why did you identify numberphone "left(Don_Mobile_Phone,4)+right(Don_Mobile_Phone,7)", that made my number wrong.. Example my number is +84973905046. Please help me resolve !!! Thank you!
Danish SiddiquiPosted Aug 15, 2014, 8:43 AM
let me if this code will work on any mobile or this code will need some specific phone models or GSM model kindly let me know as soon as possible me email id is [email protected]
Danish SiddiquiPosted Aug 15, 2014, 8:41 AM
Hello Naveed,
Bilal BhatiPosted Aug 12, 2014, 4:05 AM
plz guide ?????
Bilal BhatiPosted Aug 12, 2014, 4:05 AM
how to modify this code using mobile phone ????
Rahul MPosted Jul 22, 2014, 6:03 AM
Hi Naveed , I tried to use your sample. I am receiving exception at comm.open(). Exception message is "Can not open part <port no.> : The file is being used by some another process.". I tried with Nokia phone connected over bluetooth and Tata Photon dongle , in both the cases received same exception. Can you please suggest any workaround/solution?
merid fikaduPosted Jul 18, 2014, 4:00 AM
hi dear is it k if i use my phone like GSM modem!!!????
Vinodhini BaskarPosted Jul 12, 2014, 9:54 AM
anybody can tell how to run this program emergency
Abdullah ahmedPosted Jul 8, 2014, 8:09 AM
any webservices sir then plz email me i want to make web application plz help me [email protected]
Gil TECPosted Jul 4, 2014, 10:49 AM
thanks
mahdi ghPosted May 18, 2014, 4:13 AM
Hi how to send unicode characters?
Choujoun BououniPosted May 14, 2014, 9:13 AM
Hi can i use instead modem my phone nokia
Naveed ZamanPosted May 13, 2014, 8:23 AM
please check modem conection or check the different ports
venkadesan perumalPosted May 3, 2014, 10:00 AM
Hi Naveed Zaman , i am try to use your code , but i am getting one exception for ' No phone connected' while sent SMS. the COM Port Connected.
Raisul AlamPosted Apr 9, 2014, 11:33 PM
Dear Naveed, How to send Sender name ? Can you Help me??
Raisul AlamPosted Apr 9, 2014, 7:17 AM
Dear Naveev, Thanks a lot from the bottom of my heart, How can I run it from webform
Former memberPosted Mar 26, 2014, 3:55 AM
Hi! Great article! If you wish to send/receive mass amount of text messages with a c# example, just check out the following webiste:http://www.ozekisms.com/index.php?owpn=315&info=c_sharp_sms_example
sloqye sloqyePosted Mar 4, 2014, 3:00 PM
Thanks.
Afzal HossainPosted Feb 20, 2014, 2:25 AM
Thanks You
Afzal HossainPosted Feb 20, 2014, 2:24 AM
Nice Work........!
m vPosted Dec 21, 2013, 2:23 AM
tank you
Ali SadeghiPosted Dec 16, 2013, 2:42 AM
mr naveed thanks for your good article about sending sms. i used it and it works without any problem.but when i use words like"????" or"????? " with unicode characters as a message text it does not work and the error massage is "modem is not available" .can you please tell me what can i do for solve the problem.Thanks in advance
Naveed ZamanPosted Nov 23, 2013, 8:18 AM
thanks for the appreciation. but i am not getting the problem. modem connected but when you sending the sms it not receiving on the cell phone ? please clear the question so that i can help you out.
abc defPosted Nov 21, 2013, 11:36 PM
Naveed thanks for the article. I am getting No phone connected when sending sms, Modem connected successfully. Its airtel modem with 3G sim card. Can you please tell me what could be the reason? Thanks in advance
muthu kumarPosted Oct 3, 2013, 8:30 AM
Thanx lot its working....but did some modulation.....its working
Teboho NtoahaePosted Sep 30, 2013, 6:51 AM
hello.. Can I send an image to a cell phone using the above code? if not, do you know of anyway? thank you
Ashutosh TripathiPosted Sep 20, 2013, 7:43 AM
nice work..
varun kumarPosted Sep 18, 2013, 9:00 AM
hello naveed sir . i tried this code but some error in com1,2,3,4, . i have vodafone dongle and airtel sim . but not sended the sms,via c#,.
Hussain afridiPosted Sep 3, 2013, 12:33 PM
sir how can set the "COM1,COM2,COM3...." the fix..
Naveed ZamanPosted Sep 1, 2013, 1:00 PM
thanks for reading my article. please tell me where your got error on connection with modem or sending SMS?
akash agrawalPosted Aug 31, 2013, 2:39 PM
I m using Reliance 3g modem, your code is not working in my prospective i did all thing as you said please can you help me to successfully run your code.....
Sharad GuptaPosted Aug 31, 2013, 2:40 AM
nice one Naveed
Hussain afridiPosted Aug 29, 2013, 2:43 PM
Love you Sir Naveed for nice work... and which country you belong ??
junaid faisalPosted Aug 26, 2013, 5:31 AM
Nice work bhai jaan....................how can we reiceve sms using ur solution
Pramod LawatePosted Aug 25, 2013, 12:26 PM
Naveed great work .........it's nice article by you
Naveed ZamanPosted Aug 25, 2013, 2:13 AM
i am glade i have contributed small pace of token for my community. I love my community (C-SHARPCORNER)
anand kulkarniPosted Aug 24, 2013, 2:54 AM
Good Work
Former memberPosted Aug 22, 2013, 7:44 AM
Nice article
Abhishek JainPosted Aug 22, 2013, 7:11 AM
Nice article...
Naveed ZamanPosted Aug 22, 2013, 1:10 AM
i am honored
Ravi ShekharPosted Aug 22, 2013, 12:58 AM
Nice article..sir.
Mahesh ChandPosted Aug 21, 2013, 1:06 PM
Awesome Naveed. Thank you for taking care of it right away. Entire C# Community appreciate your work.
Naveed ZamanPosted Aug 21, 2013, 11:41 AM
thanks for your interest in my article source is added in Article Extensions
Mahesh ChandPosted Aug 21, 2013, 11:18 AM
Yes same download problem. Naveed, it will be nice if you could zip the code or upload it again?
Jay ParekhPosted Aug 21, 2013, 7:55 AM
Gives error while Downloading File GSMModem.rar