Results 1 to 12 of 12
  1. #1
    for108 is offline Member
    Join Date
    Mar 2008
    Posts
    2
    Rep Power
    0

    Default java code for send sms through http

    java code for send sms through http

  2. #2
    DonCash's Avatar
    DonCash is offline Moderator
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    240
    Rep Power
    8

    Default

    A simple Google search will be able to provide you with some answers:

    Simplewire : Java SMS SDK

    How to Send SMS using Java Program (full code sample included)

    In future, please post a more detailed explanation of your requirements.
    Did this post help you? Please me! :cool:

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Yes it is, in Google is one of the best solution to find the such details. Can find lots of resources there.

  4. #4
    prasaddasari is offline Member
    Join Date
    Nov 2008
    Posts
    1
    Rep Power
    0

    Smile Prasad

    Hi I am new to this forum.i need help sendins sms fax/email actions using java Application.Pls suggest me.

    Thanks,Prasad

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by prasaddasari View Post
    Hi I am new to this forum.i need help sendins sms fax/email actions using java Application.Pls suggest me.

    Thanks,Prasad
    You should try to workout first lol. In the first replay on this thread you can see few links, did you read them? Once you goo through all pf them, can have a clear idea about that.

  6. #6
    pranay is offline Member
    Join Date
    Dec 2008
    Posts
    1
    Rep Power
    0

    Default

    tanx for giving d stuff

  7. #7
    Helper is offline Member
    Join Date
    Jan 2009
    Posts
    2
    Rep Power
    0

    Default Send and Recevie SMS using Java

    Hi,

    Here is a sample code in Java for sending and receiving SMS:-

    Java Code:
    package javaSMS;
    
    import com.jacob.activeX.*;
    import com.jacob.com.*;
    
    public class javaSMSTest {
    	//extract "return value" as boolean, integer and assign to these variables:-
    	private static boolean bSMS;
    	private static int iSMS;
    	
    	
    	/**
    	 * @param args
    	 */
    	public static void main(String[] args) {
    		
    		//construct an object -- "SMSAPIJava", a Java wrapper for SMS class in "MobitekSMSAPI5.dll"
    		ActiveXComponent SMSAPIJava = new ActiveXComponent ("MobitekSMSAPI5.SMS");
    
    //&&&&&&&&&& connect GSM modem to computer &&&&&&&&&&&&&&&&&&
    		//call API to connect GSM modem to computer at COM port no. 2
    		//the return value of the API call is assigned to "SMSAPIReturnValue"
    		Variant SMSAPIReturnValue = SMSAPIJava.invoke("ModemInit", 2);
    		//since the return value of function "ModemInit" is an integer, so extract the return value as an integer and assign to "iSMS"
    		iSMS = SMSAPIReturnValue.getInt();
    		switch (iSMS)
    		{
    			case 0 : System.out.println("GSM modem is NOT connected to computer!"); return;
    			case 1 : System.out.println("GSM modem is connected to computer."); break;
    			case 2 : System.out.println("GSM modem is NOT connected to computer because a PIN is required!"); return;
    			case 3 : System.out.println("GSM modem is NOT connected to computer because wrong PIN is entered!"); return;
    			case 4 : System.out.println("GSM modem is NOT connected to computer because SIM card is blocked by network operator!"); return;
    			case 5 : System.out.println("GSM modem is NOT connected to computer because SIM card has problem!"); return;
    		}
    //&&&&&&&&&& end: connect GSM modem to computer &&&&&&&&&&&&&&&&&&
    		
    //!!!!!!!!!! check connection between GSM modem and GSM network !!!!!!!!!!!!!!!!!!!!!!!!	
    		//call API to check connection with GSM network, the return value of the API call is assigned to "SMSAPIReturnValue"
    		SMSAPIReturnValue = SMSAPIJava.invoke("ConnectToGSM");
    		//since the return value of "ConnectToGSM" is a boolean, so extract the return value as a boolean and assign to "bSMS"
    		bSMS = SMSAPIReturnValue.getBoolean();
    		if (bSMS)
    		{
    			System.out.println("GSM modem is connected to GSM network.");
    		}	
    		else
    		{
    			System.out.println("GSM modem is NOT connected to GSM network!");
    		}
    //!!!!!!!!!! end: check connection between GSM modem and GSM network !!!!!!!!!!!!!!!!!!!!!!!!
    		
    //~~~~~~~~~~~~~~~~ check signal strength of GSM network ~~~~~~~~~~~~~~~~~~~~~~~
    		//call API to check signal strength of GSM network, the return value of the API call is assigned to "SMSAPIReturnValue"
    		SMSAPIReturnValue = SMSAPIJava.invoke("GetSignalStrength");
    		//since the return value of "GetSignalStrength" is an integer, so extract the return value as an integer and assign to "iSMS"
    		iSMS = SMSAPIReturnValue.getInt();
    		switch (iSMS)
    		{
    			case -1 : System.out.println("Unable to get signal strength!"); break;
    			case 0 : System.out.println("NO signal strength!"); break;
    			case 1 : System.out.println("WEAK signal strength."); break;
    			case 2 : System.out.println("NORMAL signal strength."); break;
    			case 3 : System.out.println("STRONG signal strength."); break;		
    		}
    //~~~~~~~~~~~~~~~~ end: check signal strength of GSM networki ~~~~~~~~~~~~~~~~~~~~~~~
    
    //########### turn delivery status report on #######################
    		//call API to turn delivery status report on
    		//the return value of the API call is assigned to "SMSAPIReturnValue"
    		SMSAPIReturnValue = SMSAPIJava.invoke("DeliveryReportOn");
    		//since the return value of "DeliveryReportOn" is a boolean, so extract the return value as a boolean and assign to "bSMS"
    		bSMS = SMSAPIReturnValue.getBoolean();
    		if (bSMS)
    		{
    			System.out.println("Delivery status report is turned on.");
    		}
    		else
    		{
    			System.out.println("Delivery status report is NOT turned on!");
    		}
    //########### end: turn delivery status report on #######################
    		
    //------------------ send SMS ----------------------------------------
    		//set value of property; "ToNumber" is the recipient's number; "ToMessage" is the SMS to be send to the recipient
    		SMSAPIJava.setProperty("ToNumber", "0163311600");
    		SMSAPIJava.setProperty("ToMessage", "Hello from JAVA. Test DSR 6");
    		//call API to send out SMS, the return value of the API call is assigned to "SMSAPIReturnValue"
    		SMSAPIReturnValue = SMSAPIJava.invoke("SendSMS");
    		//since the return value of "SendSMS" is a boolean, so extract the return value as a boolean and assign to "bSMS"
    		bSMS = SMSAPIReturnValue.getBoolean();
    		if (bSMS)
    		{
    			System.out.println("Messange sent!");
    			
    			//try 3 times
    			for (int i=1; i<=3; i++)
    			{
    				//call API to get delivery status report, the return value of the API call is assigned to "SMSAPIReturnValue"			
    				SMSAPIReturnValue = SMSAPIJava.invoke("GetDeliveryReport");
    				//since the return value of "GetDeliveryStatusReport" is a boolean, so extract the return value as a boolean and assign to "bSMS"
    				bSMS = SMSAPIReturnValue.getBoolean();
    				
    				if (bSMS)
    				{
    					//when "GetDeluveryStatusReport = True", then get value of properties
    					int DRStatus = SMSAPIJava.getPropertyAsInt("DRStatus");										
    					String DRMNRecipient = SMSAPIJava.getPropertyAsString("DRMNRecipient");
    					String DRMsgRef = SMSAPIJava.getPropertyAsString("DRMsgRef");
    					String DRFDate = SMSAPIJava.getPropertyAsString("DRFDate");
    					String DRFTime = SMSAPIJava.getPropertyAsString("DRFTime");
    					String DRRDate = SMSAPIJava.getPropertyAsString("DRRDate");
    					String DRRTime = SMSAPIJava.getPropertyAsString("DRRTime");
    					
    					if (DRStatus == 1)
    					{
    						//System.out.println("The status of your outgoing SMS with reference number, " + DRMsgRef + ", is " + DRStatus + ".");
    						System.out.println("The status of your outgoing SMS with reference number, " + DRMsgRef + ", is delivered.");
    						System.out.println("Your outgoing SMS was received by the SMS Centre on " + DRRDate + ", at " + DRRTime + ", and was successfully delivered to " + DRMNRecipient + ", on " + DRFDate + ", at " + DRFTime + ".");
    					}
    					else
    						if (DRStatus == 0)
    						{
    							//System.out.println("The status of your outgoing SMS with reference number, " + DRMsgRef + ", is " + DRStatus + ".");
    							System.out.println("The status of your outgoing SMS with reference number, " + DRMsgRef + ", is not delivered.");
    							System.out.println("Your outgoing SMS was received by the SMS Centre on " + DRRDate + ", at " + DRRTime + ", and was NOT successfully delivered to " + DRMNRecipient + ".");	
    						}
    					else
    						if (DRStatus == 2)
    						{
    							//System.out.println("The status of your outgoing SMS with reference number, " + DRMsgRef + ", is " + DRStatus + ".");
    							System.out.println("The status of your outgoing SMS with reference number, " + DRMsgRef + ", is unknown.");
    							System.out.println("Your outgoing SMS was received by the SMS Centre on " + DRRDate + ", at " + DRRTime + ", and NO status is available.");
    						}
    						
    					break;	
    					
    				}
    				else
    				{
    					System.out.println("No delivery status report available!");
    				}
    				
    			}
    			
    		}
    		else
    		{
    			System.out.println("Messange NOT sent!");
    		}
    //------------------ end: send SMS ----------------------------------------
    		
    //+++++++++++++++++++++ read SMS ++++++++++++++++++++++++++
    		//call API to read incoming SMS, the return value of the API call is assigned to "SMSAPIReturnValue"			
    		SMSAPIReturnValue = SMSAPIJava.invoke("ReadSMS");
    		//since the return value of "ReadSMS" is a boolean, so extract the return value as a boolean and assign to "bSMS"
    		bSMS = SMSAPIReturnValue.getBoolean();
    		//if there is new SMS, then get property
    		if (bSMS)
    		{
    			//property "MN" is the sender's number			
    			String InNumber = SMSAPIJava.getPropertyAsString("MN");
    			//property "MSG" is the sender's message
    			String InMessage = SMSAPIJava.getPropertyAsString("MSG");
    			System.out.println("Number " + InNumber + ": " + InMessage );
    		}
    		else
    		{
    			System.out.println("No incoming SMS!");
    		}
    //+++++++++++++++++++++ end: read SMS ++++++++++++++++++++++++++		
    		
    		
    //------- close connection between GSM modem and computer ---------------
    		//call API to close connection between GSM modem and computer, the return value of the API call is assigned to "SMSAPIReturnValue"
    		SMSAPIReturnValue = SMSAPIJava.invoke("ModemClose");
    		//since the return value of "ModemClose" is a boolean, so extract the return value as a boolean and assign to "bSMS"
    		bSMS = SMSAPIReturnValue.getBoolean();
    		if (bSMS) System.out.println("Connection between GSM modem and computer is closed." );
    		else System.out.println("Connection between GSM modem and computer CANNOT be closed!" );		
    	}
    //------- end: close connection between GSM modem and computer ---------------
    
    }
    Source: mobitek.com.my/SMS_Gateway/SMS_API_Java/Index.htm
    Hope it helps!

    Happy coding!
    Last edited by Helper; 01-01-2009 at 03:07 AM.

  8. #8
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    I think it's better if you can provide download link of that package, since it's not a standard one for JDK. People can get wired with it.

  9. #9
    sandeep_e3 is offline Member
    Join Date
    Apr 2009
    Posts
    1
    Rep Power
    0

    Smile

    Hi hello this is sandeep.

  10. #10
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Hello Sandeep, welcome to our community :)

    Please don't do this again, if your question is not related to the original of the thread don't post it there. Choose the best sub-forum and start a new thread. And also please read our FAQ page before posting again.

  11. #11
    sysout is offline Member
    Join Date
    Aug 2009
    Posts
    66
    Rep Power
    0

    Default

    Quote Originally Posted by DonCash View Post
    A simple Google search will be able to provide you with some answers:

    Simplewire : Java SMS SDK

    How to Send SMS using Java Program (full code sample included)

    In future, please post a more detailed explanation of your requirements.
    this code doesn't have Main..it fails to run

  12. #12
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

Similar Threads

  1. Server returned HTTP response code: 500.. i need help
    By hardc0d3r in forum Java Servlet
    Replies: 9
    Last Post: 03-12-2012, 08:08 PM
  2. how to send SMS using Java API
    By sanjeevtarar in forum Advanced Java
    Replies: 4
    Last Post: 09-13-2009, 03:15 PM
  3. java.io.Exception: Server returned HTTP response code: 403
    By navishkumarb in forum Advanced Java
    Replies: 1
    Last Post: 01-05-2008, 01:33 PM
  4. Send a pic through mail, in java
    By lenny in forum Advanced Java
    Replies: 1
    Last Post: 07-25-2007, 02:49 PM
  5. Server returned HTTP response code: 500
    By Heather in forum Java Servlet
    Replies: 1
    Last Post: 07-09-2007, 04:32 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •