RunCodes
Programming & Tech

How to Send Free SMS Using C#.NET? [With Source Code]

5 4,198

As you all know guyz, the era that we are living is an era of internet, so everyone is hanging on their PC all the time. Everyday we are sending some SMS to our friends in order to inform something to them. So, if there is some method that can send SMS for free, everyone gonna use that method and loved it. Today, in this tutorial we are gonna discuss about that method using C#.NET. And also if you wanna send the message to your friends without displaying your number and name, this tutorial is for you! sometime we are in the mode of cracking jokes and wanna fool your friends or sending some threatening message(only for entertainment purpose otherwise it will be illegal) you can use this method. This method of sending SMS is called email2sms Method.

“This tutorial may be very useful for those who want to integrate SMS features in their project which is developed in C#.NET”.

For sending SMS using email2sms approach: you have to do two task:

1.   Selecting Carrier

2.    Writing C# code

we are selecting txtlocal as our carrier. So, All you have do is go to http://www.txtlocal.co.uk and there you need to create one account. after creating account. (you need to fill up some of your information and txtlocal will send you a verification email into your email and verify your account [watch the video for detail]) you have to hover your mouse over setting menu and click check box of active email2sms.

After doing this, you complete the task of selecting your carrier. Now write the following piece of code in our Visual Studio.

Now let’s start.

STEPS:

[sociallocker]

1. I am assuming that you have Visual Studio, Open your Visual Studio and click on File>new project, From the left side of your window, select Visual C#>Window and from the middle side select Windows Forms Application and then give the name of your project and then click ok which is shown in below.

2. From the ToolBox Drag and Drop four label, four Textbox and one button in your form and change the properties of these controls by selecting each control and right click that particular control and click on properties.

Four Label for phone no, gmail, password, message
Four Textbox for phone no, gmail, password, message
one Button to send

NOTE: You can increase the message box large for this select message box textbox go to properties and then change the multiline to true and ScrollBars to Both and the expand this textbox by dragging it.

3. Double click on the Send button and scroll up and then add namespace to your program as:

using System.Net;
using System.Net.Mail;

4. Now inside the clicking event of the button write the following piece of code:


string to, from, mess, pass;
MailMessage message = new MailMessage();
to = (txtPhone.Text).ToString();
from = (txtGmail.Text).ToString();
mess = (txtMessage.Text).ToString();
pass = (txtPass.Text).ToString();
message.To.Add(to);
message.From = new MailAddress(from);
message.Body = mess;
SmtpClient smtp = new SmtpClient("smtp.gmail.com");
smtp.EnableSsl = true;
smtp.Port = 587;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.Credentials = new NetworkCredential(from, pass);
try
{
smtp.Send(message);
MessageBox.Show("send successfully", "message", MessageBoxButtons.OK, MessageBoxIcon.Information);

}
catch(Exception ex)
{
MessageBox.Show(ex.Message);

}
}

5. Run your project by clicking in that play button. Input your credentials of gmail enter the phone number in which you want to send SMS and type your Message in respective textbox and then click on Send button. That’s it.

May be after sending 10 SMS your credit will be finished! but don’t be sad you can send more and more SMS but you need to create another account with another email account in www.txtlocal.co.uk ! that’s it. you may not be that much happy to hear this (sending only 10 SMS) but don’t forget you are able to send these 10 SMS for free and also there is one line “To get something, you must lose something”. it means you have to spend some time in creating account in txtlocal.co.uk in order to send free SMS.

[/sociallocker]

Finally, if you guyz think, this is awesome tutorial and help you in some extend please share this tutorials with your all friend so that they can know about this method of sending SMS!

if you have any confusion, you can watch the following video:

 

 

 

Show Comments (5)