Send SMS using VB code

By: Emiley J Viewed: 153379 times  Printer Friendly Format    


If you are looking for a simple program to send SMS from your PC using VB then here is the code.

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Private Sub Form_Load()
'Change this with the Baud rate of your modem (The one you use with Hyper Terminal)
MSComm1.Settings="9600,n,8,1"        
' Change this with the port your Modem is attached 
MSComm1.CommPort=1                     
MSComm1.PortOpen=TRUE            

End Sub

Private Sub Command1_Click()
'This line can be removed if your modem will always be in Text Mode...
MSComm1.Output = "AT+CMGF=1" & vbCrLf                          
Sleep 500
'Replace this with your mobile Phone's No.
MSComm1.Output = "AT+CMGS=+91232538538" & vbCrLf       
Sleep 1000
MSComm1.Output = "Hello This is my test message"
Sleep 2000
If InStr(MSComm1.Input, "OK") Then
    MsgBox "Message Send"
Else
    MsgBox "Message Not Send"
End If

End Sub


Most Viewed Articles (in VB.net )

Latest Articles (in VB.net)

Comment on this tutorial

Subscribe to Tutorials

Related Tutorials

Archived Comments

1. Plz. help me in getting code to read messages usin
View Tutorial          By: Jaydatta at 2009-04-03 20:58:57

2. i tried with d above code but am getting an error
View Tutorial          By: Aishwarya at 2009-04-05 04:41:17

3. aishwarya.. i also have that error.. have you solv
View Tutorial          By: Geok Lin at 2009-04-06 02:26:49

4. ha ha ha...
View Tutorial          By: fnfn at 2009-09-17 04:20:46

5. Plz tell me the classes to import for this code an
View Tutorial          By: Nitin at 2009-11-10 02:54:50

6. I got error during using above code if There is ne
View Tutorial          By: Sunil at 2009-12-28 05:22:45

7. Hi, You need to place a control on your form

View Tutorial          By: Ranjit at 2010-02-09 02:29:40

8. i am try this codeing in vb . i am using nokia n73
View Tutorial          By: kanyaraj at 2010-02-09 19:10:10

9. I have try this code.
Code has Run succeefu

View Tutorial          By: Avinash at 2010-06-07 05:38:26

10. me also i cant send.
View Tutorial          By: laurence at 2010-06-29 23:17:51

11. Hai.. i tried with d above code but am getting an
View Tutorial          By: muthupandi at 2010-08-17 09:49:23

12. Hai.. i tried with d above code but am getting an
View Tutorial          By: muthupandi at 2010-08-17 09:50:01

13. Pl provide me code to send sms using USB modems.
View Tutorial          By: Prayag Singh at 2010-09-27 22:50:34

14. Plz provide me code to send sms using modems in v
View Tutorial          By: abhishek at 2010-10-06 00:36:45

15. Free xSMSEngine.OCX To send & Receive SMS

View Tutorial          By: Mbah Lawoe at 2010-12-31 10:25:48

16. i got the MSComm control but i cant open port

View Tutorial          By: Sudhir Patil at 2011-01-25 02:10:40

17. pl tel me how to open port no

i can

View Tutorial          By: SUdhir at 2011-01-28 00:21:55

18. hi I am execute this code But message can't send <
View Tutorial          By: Sudhir Patil at 2011-02-01 10:28:28

19. pls send me code in java to send sms from pc to mo
View Tutorial          By: shreyans at 2011-02-08 07:25:57

20. i hav d same error as sudhir has "INVALID PO
View Tutorial          By: JAY SHAH at 2011-02-14 09:33:12

21. ahmm I guess This is a VB6 program? or how can I g
View Tutorial          By: kelvin at 2011-02-27 14:07:44

22. what is - MSComm1. You haven declared it as a vari
View Tutorial          By: Craig at 2011-05-01 16:37:13

23. i want source code of Send SMS on Mobile by Net.
View Tutorial          By: Ankit Patel at 2011-07-05 08:43:14

24. 1. U R NOT CONNECTED UR MOBILE WITH SYS
2.

View Tutorial          By: jAYGANESH at 2011-06-22 02:14:43

25. I used code when command button clik , it wil show
View Tutorial          By: sekh umar at 2011-06-23 01:40:21

26. The code is working for me as i have included &quo
View Tutorial          By: MOHAN at 2011-06-29 04:08:04

27. can you gave us a sample form that has a design
View Tutorial          By: niknik at 2011-07-01 09:39:21

28. I used code when command button clik , it wil show
View Tutorial          By: ashu pawar at 2011-09-26 06:38:17

29. i tried your code but i got an error on this line<
View Tutorial          By: edward at 2011-12-09 11:31:18

30. i tried your code but i got an error on this line<
View Tutorial          By: edward at 2011-12-09 11:32:30

31. MSComm1.Settings="9600,n,8,1" error run
View Tutorial          By: ali at 2012-02-25 21:46:21

32. MSComm1.Settings="9600,n,8,1"

View Tutorial          By: ali at 2012-02-25 21:52:21

33. I have ran this code but each port has raised an &
View Tutorial          By: Jawnie at 2012-03-29 07:23:22

34. Friends!
Please tell me how to sent sms mor

View Tutorial          By: Muhammad Junaid at 2012-06-18 11:37:22

35. Hi,
this is quite interesting but what if i

View Tutorial          By: Pinky Jain at 2012-08-31 07:53:42

36. I executed your code but i get the error "OK
View Tutorial          By: Denzil at 2013-01-18 09:33:37

37. can anyone tell how to send sms in asp.net using p
View Tutorial          By: dubail at 2013-04-06 14:16:25

38. can anyone tell how to send sms in asp.net using p
View Tutorial          By: dubail at 2013-04-06 14:17:44