Java Code To Send SMS Using Sms Gateway

Do you know why we need java code? Well we use java code to make web applications. Now you can use java code to send SMS using SMS gateway. Basically these days the developers or the producers use java code to create applications for the computers. So if you are thinking how to advertise your business unit’s name then use the computer to advertise it. These days everyone uses computer and mobile phones. You will hardly find someone who does not have these two electronic gadgets. It has become a necessity in our daily life.

Java code – Simple send SMS example


import no.vianett.sms.SmsEventListener;
import no.vianett.sms.Sms;
import no.vianett.sms.SmsEvent;
import no.vianett.sms.component.SmsTransceiver;
import no.vianett.sms.log.SmsScreenLogger;
import no.vianett.sms.event.SmsDeliveredEvent;
import no.vianett.sms.event.SmsSendingFailedEvent;
import no.vianett.sms.event.SmsDeliveryFailedEvent;
public class SmsSender implements SmsEventListener
{
    private SmsTransceiver transceiver = null;
    private Object link = null; // Just to keep this object alive.
    private int counter = 0;
    public SmsSender()
    {
        this.link = this; // Keeps this object alive.
        this.transceiver = SmsTransceiver.getInstance(); // Get the transceiver object.
        // Initialize transceiver.
        String smsHost = “cpa.vianett.no”;
        String smsPort = “31337”;
        String smsUsername = “username”;
        String smsPassword = “password”;
        this.transceiver.initialize( smsHost, Integer.parseInt( smsPort ), smsUsername, smsPassword, newSmsScreenLogger() );
        this.transceiver.addSmsEventListener( this ); // Registrer this class as listener for SMS events.
        // Send message
        Sms sms = new Sms();
        sms.setId( ++this.counter );
        sms.setReplyPath( 100 );
        sms.setSender( “1963” ); // Set the sender number.
        sms.setMessage( “Hello World!” );
        sms.setRecipient( “xxxxxxxx” ); // The recipients phone number.
        this.transceiver.send( sms );
    }
    // Just make new instance of this class.
    public static void main( String[] args ){ new SmsSender(); }
    /**
    * Listener.
    *
    * @param event a <code>no.vianett.sms.SmsEvent</code>
    */
    public void eventHappened( SmsEvent event )
    {
        if( event instanceof SmsDeliveredEvent )
        {
            System.out.println( “Sms delivered.” );
            System.out.println( “Refno : ” + event.getReferenceId() );
            System.out.println( “Sms generated by : ” + event.getSource().getClass() );
        }
        else if( event instanceof SmsSendingFailedEvent )
        {
            System.out.println( “Sms sending failed.” );
            System.out.println( “Refno : ” + event.getReferenceId() );
            System.out.println( “Return code : ” + ( ( SmsSendingFailedEvent ) event ).getReturnCode() );
            System.out.println( “Sms generated by : ” + event.getSource().getClass() );
        }
        else if( event instanceof SmsDeliveryFailedEvent )
        {
            System.out.println( “Sms delivery failed.” );
            System.out.println( “Refno : ” + event.getReferenceId() );
            System.out.println( “Error code : ” + ( ( SmsDeliveryFailedEvent ) event ).getErrorCode() );
            System.out.println( “Sms generated by : ” + event.getSource().getClass() );
        }
    }
}

Source: vianett.com/en/developers/api-code-examples/java

Send SMS through internet is the best option these days. You just need a computer or a laptop and a reliable internet connection to do this job. Since you are a business owner you need to travel, so wherever you are you can use the internet to send SMS to your existing customer. This facility does not restrict anyone within a certain boundary. Since you are using internet you can find thousands of phone number of people and you can make them your potential customers. Just be honest with your service. If you are new in this field you have to give the best to all your customers. There are many business owners these days and more or less everyone gives the same service or product. If you are true to your customers they will remain with you forever.

If you are thinking of giving some special discounts then send SMS through internet tell your existing customers about it. Let them know few days before hand so that they can come to you and avail the discount. Wish your customers on their birthdays, on some occasions, these are few ways to stay in touch with them and make them feel special. Everyone likes to receive messages on the days of festivals. Seeing the message they will definitely come to you. If possible write down their first name, this works better. Customers will think that you remember them.

Since all business units have internet connection in their offices these days you do not need to pay extra money. In fact this is the easiest, cheapest and the most reliable way to market a product. If you are launching a new product or service in the market just send a SMS to the people they will come to know about it within seconds. Hardly there will be any waste age of money or energy. In fact if you call up some one unknown they might not like it or maybe they are busy doing something important. So it is better to drop a message in the inbox. Whenever the receiver is free he or she will invest some time to read your message. And if they think it is important they will surely reply back. Please do not charge any extra amount for a reply back. Always take feedback positively. The more and more your customers reply back you should be happy thinking they really want your business to improve.

GET THE BEST APPS IN YOUR INBOX

Don't worry we don't spam

We will be happy to hear your thoughts

Leave a reply

Login/Register access is temporary disabled