How to send sms through java program?

hi,
i am trying to send sms through java program.i am usining ubuntu 6.04.i am using modem MC35i.i use the jSMSEnjine.jar and rxtxcomm.jar.
these are the following program.
import org.jsmsengine.*;
import java.util.*;
class SendMessage
     public static void main(String[] args)
          int status;
          // Create jSMSEngine service.
     CService srv = new CService("Com2",9600);
          //CService srv = new CService("COM2",9600);
          System.out.println();
          System.out.println("SendMessage(): sample application.");
          System.out.println(" Using " + srv._name + " " + srv._version);
          System.out.println();
          try
               //     Initialize service.     
               srv.initialize();
               Thread thread =Thread.currentThread();
               thread.sleep(1000);
               System.out.println(srv);
               //     Set the cache directory.
               srv.setCacheDir(".\\");
               //     Set the phonebook.
               //     srv.setPhoneBook("../misc/phonebook.xml");
               //     Connect to GSM device.
               status = srv.connect();
               //     Did we connect ok?
               int st=CService.ERR_OK;
               System.out.println(st);
               System.out.println(status);
               if (status == CService.ERR_OK)
                    //     Set the operation mode to PDU - default is ASCII.
                    srv.setOperationMode(CService.MODE_PDU);
                    // Set the SMSC number (set to default).
                    srv.setSmscNumber("");
                    //     Print out GSM device info...
                    System.out.println("Mobile Device Information: ");
                    System.out.println("     Manufacturer : " + srv.getDeviceInfo().getManufacturer());
                    System.out.println("     Model : " + srv.getDeviceInfo().getModel());
                    System.out.println("     Serial No : " + srv.getDeviceInfo().getSerialNo());
                    System.out.println("     IMSI : " + srv.getDeviceInfo().getImsi());
                    System.out.println("     S/W Version : " + srv.getDeviceInfo().getSwVersion());
                    System.out.println("     Battery Level : " + srv.getDeviceInfo().getBatteryLevel() + "%");
                    System.out.println("     Signal Level : " + srv.getDeviceInfo().getSignalLevel() + "%");
                    //     Create a COutgoingMessage object and dispatch it.
                    //     *** Please update the phone number with one of your choice ***
// String smsLengthTest="Hi"+"\nTesting is going on.Test for sending unlimited number of charecter.So you will get N number of SMS.Initially I trancate the whole string by 70 charecter.Later I will put it upto 90 charecter.Some chararecter should kept for header portion.I don't know the total number.It is just test.If you got the sms u should appreciate me...This is Ripon...I have written sms program";
String smsLengthTest="Hi\n"+"This is Govindo";
int mao=smsLengthTest.length();
System.out.println("Length of sms :"+mao);
String smsNo="9433314095";
smsNo="+91"+smsNo;
if(mao<70)
COutgoingMessage msg = new COutgoingMessage(smsNo,smsLengthTest);
//     Character set is 7bit by default - lets make it UNICODE :)
//     We can do this, because we are in PDU mode (look at line 63). When in ASCII mode,
//          this does not make ANY difference...
msg.setMessageEncoding(CMessage.MESSAGE_ENCODING_UNICODE);
if (srv.sendMessage(msg) == CService.ERR_OK) System.out.println("Message Sent!");
else System.out.println("Message Failed!");
else
// COutgoingMessage msg = new COutgoingMessage(smsNo,smsLengthTest);
// LinkedList messageList;
// messageList = new LinkedList();
// messageList.add(msg);
// LinkedList maooo=new LinkedList();
// maooo=srv.splitLargeMessages(messageList);
int sizelength=0;
int counter=0;
sizelength=smsLengthTest.length();
System.out.println("SMS length :"+sizelength);
int smsCntr=sizelength/70;
System.out.println("smsCntr :"+smsCntr);
counter=smsCntr+1;
int j=70;
int k=0;
try
for(int i=0;i<smsCntr;i++)
String test="";
test=test+i;
test=smsLengthTest.substring(k,j);
System.out.println(test);
System.out.println(test.length());
COutgoingMessage msg = new COutgoingMessage(smsNo, test);
System.out.println("hi this is suman" + smsNo);
//     Character set is 7bit by default - lets make it UNICODE :)
//     We can do this, because we are in PDU mode (look at line 63). When in ASCII mode,
//          this does not make ANY difference...
msg.setMessageEncoding(CMessage.MESSAGE_ENCODING_UNICODE);
if (srv.sendMessage(msg) == CService.ERR_OK) System.out.println("Message Sent!");
else System.out.println("Message Failed!");
k=k+70;
j=j+70;
catch(Exception e)
System.out.println("Error...1");
e.printStackTrace();
e.getMessage();
String lastPortion=smsLengthTest.substring(k);
System.out.println(lastPortion);
COutgoingMessage msg = new COutgoingMessage(smsNo, lastPortion);
//     Character set is 7bit by default - lets make it UNICODE :)
//     We can do this, because we are in PDU mode (look at line 63). When in ASCII mode,
//          this does not make ANY difference...
msg.setMessageEncoding(CMessage.MESSAGE_ENCODING_UNICODE);
if (srv.sendMessage(msg) == CService.ERR_OK) System.out.println("Message Sent!");
else System.out.println("Message Failed!");
                    // Disconnect from GSM device.
                    srv.disconnect();
               else System.out.println("Connection to mobile failed, error: " + status);
          catch (Exception e)
               e.printStackTrace();
          System.exit(0);
the error is:
SendMessage(): sample application.
Using jSMSEngine API 1.2.6 (B1)
org.jsmsengine.CService@addbf1
0
-101
Connection to mobile failed, error: -101
please help me,its very urgent.

come back in about 5 years, we may have time for you by then.
In the meantime, how about contacting the people who wrote that library and asking them nicely for help (rather than trying to order people to drop whatever they're doing and jump through hoops to accommodate your every wish as you're doing here)?

Similar Messages

  • How to send SMS from Java program?

    Hello,
    I want to know, how can I send SMS from Java program.I dont have any idea about SMS gateways. Can any one give me Sample code for sending the SMSs from Java Program.
    Thanks,
    -BR

    hi,
    refer javamail concepts
    http://www.google.co.in/search?q=javamail+simple+example&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a

  • How to send mail through java program in solaris server

    hi
    i am writing java code to send the mail using my company SMTP
    ,the program is working fine when i run and deploy in windows environment
    but at the same time when i deploy the war to sun solaris server ,it is not working
    and throwing the Error saying
    java.lang.Exception: Invalid Addresses; nested exception is:      javax.mail.SendFailedException: 553 sorry, that domain isn't allowed to be relayed thru this MTA without authentication #5.7.1     at jsp.SendMail._jspService(_SendMail.java:137)
    i am using the Authentication also using user id and password of same domain and it is able to authenticate
    in windows but not in Solaris
    where i am making mistake plz
    guide.
    Saurabh

    thanks Alan
    but i think there is some other problem because same code is
    working when i am using in windows as well as i am using authentication method
    also but it is not working when running in Solaris Environment
    here is the code i am using to send the mail
    props.setProperty("mail.transport.protocol", "smtp");
    props.setProperty("mail.host", "smtp.mycompany.com");//smtp protocol for IIBF
    props.put("mail.smtp.starttls.enable","true");//setting start TLS to be true
    props.put("mail.smtp.auth", "true");// authentication is false
    props.put("mail.smtp.port", port);//setting the port number it can be either 25 or 587
    props.put("mail.smtp.username", "noreply");
    props.put("mail.smtp.password","noreply");
    props.put("mail.debug", "true");
    Authenticator auth = new SMTPAuthenticator();
    Session session1 = Session.getDefaultInstance(props);
    java.util.Properties sessionProperties = new java.util.Properties();
    sessionProperties.put("mail.smtp.auth", "true");
    message.setFrom(new javax.mail.internet.InternetAddress(From ,"name"));
    message.addRecipient(javax.mail.Message.RecipientType.TO, new javax.mail.internet.InternetAddress(To));
    message.setText(TextCo);
    message.setSubject(subject);
    message.setContent(boyd, "text/plain");
    message.reply(true);
    Transport trans = session1.getTransport("smtp");
    trans.connect(SMTP_HOST_NAME, SMTP_AUTH_USER, SMTP_AUTH_PWD);
    boolean ddd = trans.isConnected();
    message.saveChanges();
    trans.sendMessage(message, message.getAllRecipients());
    above code is working properly in windows but not in Solaris
    plz guide what next to do
    thankx in advance
    saurabh

  • Is it possible to send SMS through java

    Hi all
    I m a student and as a part of my project I need to create an SMS server(SMS gateway). Can we send SMS through Java and if yes then send me the code for the same . Also on which GSM Modem will it Work , I've heard about Nokia GSM Modem N32. Kindly Guide me regarding the Same.
    Regards
    MoComp

    Hi all
    I m a student and as a part of my project I need to
    create an SMS server(SMS gateway). Can we send SMSSo YOU need to write it.
    through Java and if yes then send me the code for theIt's possible, as there are several commercial offerings out there.
    But as YOU need to write it it won't do for you to try and trick someone else into writing it so you can submit it as your own.
    same . Also on which GSM Modem will it Work , I've
    heard about Nokia GSM Modem N32. Kindly Guide me
    regarding the Same.All depends on how you implement it.
    A real server would have its own hardware and software to pipe directly into the network of a telco, and a contract with that telco to use their network to send messages.

  • I can send sms through java but now i need help for.......???

    hi i am working on a project where i have to read and send sms automaticaly.i succesfully build it also with the jsmsengine and nokia 3220 mobile phone and now i have to fix up some bugs.any interested candidate can contact with me so that we can fix those bug and i also want to know how can i send EMS through mobile.
    is ther any java api that can better that the jsmsengine api??
    thanx

    How did you move you rlibrary to the external drive?
    Did you follow these steps -> iTunes: Moving your iTunes Music folder
    or did you simply drag it over?
    Don't just drag it over.
    This morning, I attempted to download itunes to the new external drive so I could play and easily import my music from there, and itunes won't download to the external hard drive! The error message I'm getting says itunes will only download to the startup disk/
    Do you mean you are trying to download the iTunes program so you can install it?

  • How to send fax using java programming

    i need to send files in my hard disk through fax using java programming.
    i have found on the internet that it is possible to be implemented by using java.comm API and JTAPI. however, i don't know how...does anyone can tell me the details? also, as i know it will be a big project to send fax using such API. is that any other simple way to implement the fax function in java? thx a lot!

    To cse.mahbub:
    Are you aware that you replied to a 5 1/2 year old question?
    Please don't do that. Reply only to current questions.

  • How to send SMS using java

    Dear All
    How we can send SMS(Short Message Service) to mobile phones using java.
    By Registering in some sites and using that user name and password we can send SMS.
    But after some limited SMS we have to pay for further use.
    I need some thing which we can use as free.
    Can any one help me
    Thanks in Advance

    The easiest way would be to send a regular email to a Email to SMS gateway.
    Check out the list of Email to SMS gateways at http://en.wikipedia.org/wiki/SMS_gateways

  • How to send sms from java code

    hi
    I have involved in a project where I need to send sms to mobile from java code.Can anyone help me.if u have code please send me.
    thanks
    dhinesh

    Hi,
    there are several methods to do so but using Web Services is an easier one. Google will help you to find a provider. (E.x. http://www.remotemethods.com/home/communic/sms .)
    Best wishes,
    Christian Ullenboom | http://www.tutego.com/

  • How to Send SMS through SAP?

    Hello friends,
                      I got know tht Function module SO_OBJECT_SEND is used to send SMS to customer after inquiry is created. Here in receivers pass the values as mobilenumber "at"domain.com/org etc....but i am not getting the correct information an anyone share me the procedure for triggering SMS?
    Thks points will be rewarded for helpful answer.

    Hi Venkateswar,
    As i already tld u have to pass same parameters which we will pass for mail sending. U can get plenty of sample codes for mail sending in SDN itself. Only difference is data of receivers parameter. Check below code.
          SELECT SINGLE cell_carr_string
          FROM zcarrier
          INTO w_carr
          WHERE zcarrier EQ wa_zsent-cell_carrier.
          IF sy-subrc EQ 0.
            REFRESH i_rec[].
            CONCATENATE wa_zsent-cell_number
                                    w_carr  INTO w_email.
    i_rec-receiver = w_email.*
    i_rec-rec_type = 'U'.              "internet*
            APPEND i_rec.
    ENDIF.
              CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
                EXPORTING
                  document_data                    = doc_chng
               document_type                    = 'RAW'
                TABLES
               object_content                   = objcont
                  receivers                        = i_rec
             EXCEPTIONS
               too_many_receivers               = 1
               document_not_sent                = 2
               document_type_not_exist          = 3
               operation_no_authorization       = 4
               parameter_error                  = 5
               x_error                          = 6
               enqueue_error                    = 7
               OTHERS                           = 8
    Thanks,
    Vinod.

  • How to Send SMS through XI (PI)

    Hi
    Can you explain how to communicate XI with a SMPP server (SMS Server)? I have a requirement to send notifications to the users through SMS.
    Do we have a separate Adapter to communicate with ?
    Please help on this.
    Thanks & Regards,
    Chaminda.

    Hello..
    No need for separate adapter, you can use HTTP adapter for the same..
    Also check these links for PI communication to Fax and SMS systems
    Connect to Fax by SAP XI
    http://wiki.sdn.sap.com/wiki/display/XI/SMTPConfigurationinSAPXI
    Regards
    Suraj

  • Send mail through Java program. ERROR javax.mail.MessagingException: [EOF]

    Hi,
    i've a java Mail program which will send the mail thro smtp server.
    when i try to execute this program im getting the error javax.mail.MessagingException: [EOF]
    i've attached both code & error.
    while running the program need to give the arguments
    ex : java SendMail smtpserver frommailid tomailid subject body
    please provide me the solution.
    import javax.mail.*;
    import javax.mail.internet.*;
    import java.util.*;
    public class SendMail {
         public static void main(String[] args) {
              try
         String smtpServer=args[0];
         String to=args[1];
         String from=args[2];
         String subject=args[3];
         String body=args[4];
         send(smtpServer, to, from, subject, body);
         catch (Exception ex)
         System.out.println("Usage: java SendMail"
         +" smtpServer toAddress fromAddress subjectText bodyText");
         System.exit(0);
         public static void send(String smtpServer, String to, String from
                   , String subject, String body)
                   try
                   Properties props = System.getProperties();
                   props.put("mail.smtp.host", smtpServer);
                   Session session = Session.getDefaultInstance(props, null);
                   Message msg = new MimeMessage(session);
                   msg.setFrom(new InternetAddress(from));
                   msg.setRecipients(Message.RecipientType.TO,InternetAddress.parse(to, false));
                   msg.setSubject(subject);
                   msg.setText(body);
                   msg.setSentDate(new Date());
                   System.out.println("test 1--");
                   Transport.send(msg);
                   System.out.println("test 2--");
                   System.out.println("Message sent OK.");
                   catch (Exception ex)
                   ex.printStackTrace();
    thanks for the help in advance.
    regs
    lal.

    I ran into a similar error today. I fixed it by setting up SMTP authentication because my ISP's help pages said that they would allow only SMTP authentication.
    Here is what I did:
    Transport transport =
    mailConnection.getTransport("smtp");
    transport.connect(
    "hostname", "email", "password");
    Transport.send(msg);
    I also passed the following property while creating the session:
    props.put("mail.smtp.auth", "true");
    finally turning on debug helped:
    session.setDebug(true);
    session.setDebugOut(null);
    Hope this helps

  • How to send images through java or RMI.?

    Hello,
    I have a problem with RMI. I had created a canvas on which you can draw anything then when clicking send button this drawing should be reach to another client(s). so please guide me how to do it. and also please give some code if possible.
    thanks very much.
    umesh m joshi

    Hello RoopaSri:
    Umm, I don't think it will help in his case. He means to send a drawing from a canvas and not a image file.So that is back to his question
    hello umjosh ,
    you can get an image object from the Graphics class and RMI the bytes gotten from the image object. U can find in this forum on how to save the canvas. instead of saving, u can send the bytes.
    eg Imageicon imgIcon=new Imageicon("imagefile.jpg");
    and send it to the remote object. Use
    ImageIcon.getImage can used to exrtract the image.
    Hope this helped.
    Regards,
    Roopa Vittal
    developer technical Support
    SUN Microsystems.

  • SMS through ABAP Program

    Hi Experts,
    How can we send sms through ABAP program. What are the web services required? Is there any tutorial/resource on this topic?
    Regards.
    Abdullah

    Hi...
    Go through this code.....
    REPORT  y_sms_to_india620.
    DATA: http_client TYPE REF TO if_http_client .
    DATA: wf_string TYPE string ,
          result TYPE string ,
          r_str TYPE string .
    DATA: result_tab TYPE TABLE OF string.
    SELECTION-SCREEN: BEGIN OF BLOCK a WITH FRAME .
    PARAMETERS: mail(100) LOWER CASE,
                m_no(20) LOWER CASE ,
                m_mss(120) LOWER CASE.
    SELECTION-SCREEN: END OF BLOCK a .
    START-OF-SELECTION .
      CLEAR wf_string .
      CONCATENATE
      'http://www.webservicex.net/SendSMS.asmx/SendSMSToIndia?MobileNumber='
      m_no
      '&FromEmailAddress='
      mail
      '&Message='
      m_mss
      INTO wf_string .
      CALL METHOD cl_http_client=>create_by_url
        EXPORTING
          url                = wf_string
        IMPORTING
          client             = http_client
        EXCEPTIONS
          argument_not_found = 1
          plugin_not_active  = 2
          internal_error     = 3
          OTHERS             = 4.
      CALL METHOD http_client->send
        EXCEPTIONS
          http_communication_failure = 1
          http_invalid_state         = 2.
      CALL METHOD http_client->receive
        EXCEPTIONS
          http_communication_failure = 1
          http_invalid_state         = 2
          http_processing_failed     = 3.
      CLEAR result .
      result = http_client->response->get_cdata( ).
      REFRESH result_tab .
      SPLIT result AT cl_abap_char_utilities=>cr_lf INTO TABLE result_tab .
      LOOP AT result_tab INTO r_str.
        WRITE:/ r_str .
      ENDLOOP .
    Reward if it helps u...

  • How to store xml data into file in xml format through java program?

    HI Friends,
    Please let me know
    How to store xml data into file in xml format through java program?
    thanks......
    can discuss further at messenger.....
    Avanish Kumar Singh
    Software Engineer,
    Samsung India Development Center,
    Bangalore--560001.
    [email protected]

    Hi i need to write the data from an XML file to a Microsoft SQL SErver database!
    i got a piece of code from the net which allows me to parse th file:
    import java.io.IOException;
    import org.xml.sax.*;
    import org.xml.sax.helpers.*;
    import org.apache.xerces.parsers.SAXParser;
    import java.lang.*;
    public class MySaxParser extends DefaultHandler
    private static int INDENT = 4;
    private static String attList = "";
    public static void main(String[] argv)
    if (argv.length != 1)
    System.out.println("Usage: java MySaxParser [URI]");
    System.exit(0);
    String uri = argv[0];
    try
    XMLReader parser = XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
    MySaxParser MySaxParserInstance = new MySaxParser();
    parser.setContentHandler(MySaxParserInstance);
    parser.parse(uri);
    catch(IOException ioe)
    ioe.printStackTrace();
    catch(SAXException saxe)
    saxe.printStackTrace();
    private int idx = 0;
    public void characters(char[] ch, int start, int length)
    throws SAXException
    String s = new String(ch, start, length);
    if (ch[0] == '\n')
    return;
    System.out.println(getIndent() + " Value: " + s);
    public void endDocument() throws SAXException
    idx -= INDENT;
    public void endElement(String uri, String localName, String qName) throws SAXException
    if (!attList.equals(""))
    System.out.println(getIndent() + " Attributes: " + attList);
    attList = "";
    System.out.println(getIndent() + "end document");
    idx -= INDENT;
    public void startDocument() throws SAXException
    idx += INDENT;
    public void startElement(String uri,
    String localName,
    String qName,
    Attributes attributes) throws SAXException
    idx += INDENT;
    System.out.println('\n' + getIndent() + "start element: " + localName);
    if (localName.compareTo("Machine") == 0)
    System.out.println("YES");
    if (attributes.getLength() > 0)
    idx += INDENT;
    for (int i = 0; i < attributes.getLength(); i++)
    attList = attList + attributes.getLocalName(i) + " = " + attributes.getValue(i);
    if (i < (attributes.getLength() - 1))
    attList = attList + ", ";
    idx-= INDENT;
    private String getIndent()
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < idx; i++)
    sb.append(" ");
    return sb.toString();
    }// END PRGM
    Now , am not a very good Java DEv. and i need to find a soln. to this prob within 1 week.
    The next step is to write the data to the DB.
    Am sending an example of my file:
    <Start>
    <Machine>
    <Hostname> IPCServer </Hostname>
    <HostID> 80c04499 </HostID>
    <MachineType> sun4u [ID 466748 kern.info] Sun Ultra 5/10 UPA/PCI (UltraSPARC-IIi 360MHz) </MachineType>
    <CPU> UltraSPARC-IIi at 360 MHz </CPU>
    <Memory> RAM : 512 MB </Memory>
    <HostAdapter>
    <HA> kern.info] </HA>
    </HostAdapter>
    <Harddisks>
    <HD>
    <HD1> c0t0d0 ctrl kern.info] target 0 lun 0 </HD1>
    <HD2> ST38420A 8.2 GB </HD2>
    </HD>
    </Harddisks>
    <GraphicCard> m64B : PCI PGX 8-bit +Accel. </GraphicCard>
    <NetworkType> hme0 : Fast-Ethernet </NetworkType>
    <EthernetAddress> 09:00:30:C1:34:90 </EthernetAddress>
    <IPAddress> 149.51.23.140 </IPAddress>
    </Machine>
    </Start>
    Note that i can have more than 1 machines (meaning that i have to loop thru the file to be able to write to the DB)
    Cal u tellme what to do!
    Even better- do u have a piece of code that will help me understand and implement the database writing portion?
    I badly need help here.
    THANX

  • How to send sms to mobile from tomcatserver using java code?

    Hi,
    Could you please let me know that,
    How to send sms to mobile from tomcatserver using java code? Please provide the code snippet.
    Thanks in advance.

    Yes, but something needs to send that message. You can't just take an arbitrary computer and send an SMS, it does not have the hardware to do that.
    So either you have a mobile through which you do that or more likely - you use some sort of online service to do it. Whatever choice you make will determine what code you will have to write to get it done. Nobody is going to deliver the code to you, that's your job. It is also your job to figure out what service you are going to use.

Maybe you are looking for

  • Can't get iphoto to work after tampering with library in Finder

    I think I made a big mistake when I tampered with the iphoto library in Pictures in Finder. Now I can't get iphoto to work. All the pictures are gone in iphoto, the spaces are there but they are blank. When I open iphoto it goes into the mode (little

  • Movement type for blocking to a different storage location

    Hi Gurus, Is there any movement type by which the stock should move to blocked from unrestricted but to a different storage location. In the mvt type 344, the stock moves from unres to blocked but it is in the same location. Regards, Kumar

  • SQL Cluster - Unable to obtain IP Address from System Center IP Pool

    Hi everyone, we are trying to deploy a SQL cluster into a windows azure pack tenant cloud. Our azure pack environment contains: - 4X Hyper-V server in a failover cluster - 1X SCVMM server - multiple WAP server Steps we have done: -    Windows failove

  • Deploying mdb in weblogic 9.0

    i have a simple mdb aplication .. i have deloyed it in weblogic 9.0.. but it is showing error in connection factory JNDI Name..like replace the JNdi name .. pls hel me out to solve the problem thank u

  • Total resetting WRT54G v2

    Im not able to access the routers configuration (via HTTP://192.168.1.1) "Cannot locate remote server..." Ive read many of the post on this forum but not found anyting that helps... so below is some facts and things ive tried: Resetting (10 or 30 sec