Sending SMS Messages with Visual Basic. Introduction. We all know what an SMS is (hopefully!), but sadly, SMS is said to be a dying medium of communication. I honestly do not actually think it is, because most countries are still battling with proper internet communication, and the fact that internet prices are quite expensive, especially in South Africa. Anyway, enough rambling. Name it anything you like and design your project to resemble Figure 1.
SMS Sending in C# SMS Sending in VB.NET. To send an SMS from within your VB.NET code.
Figure 1: Our Design. You may name your objects anything you like; but, keep in mind that my object names may be different than yours. If you want to follow my example to the letter, here is the resulting XAML code for this design: < Page. Class=. Add the following code to add the appropriate namespaces and their functionalities to your project: Imports System. Imports Windows. Devices.
Sms. This simply imports SMS communication capabilities to your project. Speaking about capabilities, you could also add this capability to your project. To add any Capability to a project, follow these steps: Double- click Package. Solution Explorer, as shown in Figure 2.
Figure 2: Solution Explorer. This will produce the screen as shown in Figure 3. Figure 3: Settings.
- Sending SMS Using PC COM Port Using VB.NET. Windows Insider Program Microsoft Affliate Program.
- VB.NET SQL Example: How to send SMS in. How to send SMS in VB.NET using SQL database. I thought I share this code snippet because I find this way of SMS sending.
- How to send SMS from Applications?
- VB.NET SQL Example: How to send SMS in VB.NET using SQL database.
Select the Capabilities tab and choose it from the items in the list. You also could click on Project, Properties and click the Package Manifest. Here are a few articles that can assist you to get started with Windows Phone apps: Add a modular variable. This is a variable object that will be used through all the objects on the page: Private sd. Device As Sms. Device.
To use this script, simply register for free and get 5 free SMS. Dim s As New ViaNettSMS.
Add the following code behind the button labeled Send: Private Async Sub btn. Send? Well, I honestly did not think it will be so easy. Okay, it is not easy code, but it is not too overly complicated either! What happens in this sub is set out in the following list: The Sub itself has been changed to Async, because it will deal with an Asynchronous process. If you have not heard about Async yet, I suggest you read the following article: Async Programming with Visual Basic and Windows 8 / 8. It then tries to get hold of a valid SMS capable device. If it cannot find a valid device, it will do nothing; else, it will continue to the next Try & Catch block.
If you have never encountered a Try & Catch block before, I recommend this (somewhat old) article: Handling Exceptions in Visual Basic. Inside the last Try & Catch block, it simply set up the SMS message to be sent. I provided the number to where the SMS should be sent, as well as the body of the SMS.
Then, I send the message. Easy as Pie! Receiving SMSs. Add the following modular variable: Private bln. Listening As Boolean.
This flag indicates that the device is listening for incoming messages. Add the next code segment behind the btn. Recieve button's Click event: Private Async Sub btn. Receive. There is one spanner in the works, however. Notice the Add. Handler line?
Well, this line creates a handler named sd. Device. Sms. Message. Recieved that is the actual method that will show the SMS details—note, not the content, just the details such as where this message is from. I may talk about reading SMSs later. Add the sd. Device. Sms. Message. Recieved event now: Private Async Sub sd. Device. If you have not yet read my article about Async Programming that I spoke about, I suggest you do so now.
Reading an SMSAdd another button your page and name it btn. Read. Give it a content value of Read. This button will be used to read the physical SMS that has been received. Add its code now: Private Async Sub btn.
Read! First, it determines whether or not we have a valid SMS device. If it is dealing with a valid SMS device, it will continue to the next steps; else, it will not do anything. Because space is very limited, I decided not to put too many controls onto the page. So, excuse the fact that it will keep on using txt. Send. To and txt. Body, although for a different purpose. The text gets cleared, and then it establishes the total number of messages received.
If there are more than 0 received, it determines what type of message it is. If it is a Text message, it converts the binary message to a text message and simply displays it. Conclusion. I hope you have enjoyed this article. Until next time, cheers! About the Author.
Hannes du Preez is a Microsoft MVP for Visual Basic for the seventh year in a row.
Sending SMS in VB. NET (AT COMMANDS)Note: Due to the size or complexity of this submission, the author has submitted it as a . After downloading it, you will need a program like Winzip to decompress it. Virus note: All files are scanned once- a- day by Source. Codester. com for viruses, but new viruses come out every day, so no prevention program can catch 1. FOR YOUR OWN SAFETY, PLEASE: 1. Re- scan downloaded files using your personal virus checker before using it.
NEVER, EVER run compiled files (.