Logo 
Search:

Unix / Linux / Ubuntu Forum

Ask Question   UnAnswered
Home » Forum » Unix / Linux / Ubuntu       RSS Feeds

send sms programme

  Asked By: Ravi    Date: Jan 19    Category: Unix / Linux / Ubuntu    Views: 1351
  

can u send me the programe for sending the sms to mobile using java and instruction to build the code

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Abhishek Singh     Answered On: May 23

Yes,we can send SMs Using our Java Program.These are the steps Note:Ipipi allows you to send only 5 sms free of cost,After that create one more account 1> create an account in http://www.ipipi.com/ 2>I created Account like this: username: surajSMS password: suraj1233>Prepare the program in this way SendSMS.java
?12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 import java.io.*; import java.net.InetAddress; import java.util.Properties; import java.util.Date; import javax.mail.*; import javax.mail.internet.*; import javax.activation.*; public class SendSMS { public SendSMS() {} //create an account on ipipi.com with the given username and password public void msgsend() { String username = "surajSMS"; //Your Credentials String password = "suraj123"; String smtphost = "ipipi.com"; //Ip/Name of Server String compression = "None"; //I dont want any compression String from = "surajSMS@ipipi.com"; //ur userid@ipipi.com //This mobile number need not be registered with ipipi.com String to = "919861098610@sms.ipipi.com"; //mobile number where u want to send sms String body = "Hi This Msg is sent through Java Code"; Transport tr = null; try { Properties props = System.getProperties(); props.put("mail.smtp.auth", "true"); // Get a Session object Session mailSession = Session.getDefaultInstance(props, null); // construct the message Message msg = new MimeMessage(mailSession); //Set message attributes msg.setFrom(new InternetAddress(from)); InternetAddress[] address = {new InternetAddress(to)}; msg.setRecipients(Message.RecipientType.TO, address); msg.setSubject(compression); msg.setText(body); msg.setSentDate(new Date()); tr = mailSession.getTransport("smtp"); //try to connect tr.connect(smtphost, username, password); msg.saveChanges(); //send msg to all recipients tr.sendMessage(msg, msg.getAllRecipients()); tr.close(); } catch (Exception e) { e.printStackTrace(); } } public static void main(String[] argv) { SendSMS sms = new SendSMS(); sms.msgsend(); System.out.println("Successfull"); } }

 
Answer #2    Answered By: Abhishek Singh     Answered On: May 23

1.import com.simplewire.sms.*;
2.
3.public class send_text
4.{
5. public static void main(String[] args) throws Exception
6. {
7. SMS sms = new SMS();
8.
9. // Subscriber Settings
10. sms.setSubscriberID("123-456-789-12345");
11. sms.setSubscriberPassword("Password Goes Here");
12.
13. // Optional Message Settings
14. // Specify source and destination ports that will appear
15. // in the GSM User-Data-Header
16. //sms.setSourcePort((short)0x0000);
17. //sms.setDestPort((short)0x0000);1
8. //
19. // Specify a network type "hint" - helps Simplewire
20. // choose between a TDMA vs. GSM network for example.
21. // Only useful for certain types of messages such as
22. // WAP push or MIDP Java WMA messages and if the destination23. // operator runs both TDMA and GSM networks.
24. // sms.setNetworkType(SMS.NETWORK_TYPE_GSM);
25.26. // Message Settings27. sms.setMsgPin("+11005101234");
28. sms.setMsgFrom("Demo");
29. sms.setMsgCallback("+11005551212");
30. sms.setMsgText("Hello World From Simplewire!");
31.
32. System.out.println("Sending message to Simplewire...");
33.
34. // Send Message
35. sms.msgSend();
36.
37. // Check For Errors
38. if(sms.isSuccess())
39. {
40. System.out.println("Message was sent!");
41. }
42. else
43. {
44. System.out.println("Message was not sent!");
45. System.out.println("Error Code: " + sms.getErrorCode());
46. System.out.println("Error Description: " + sms.getErrorDesc());
47. System.out.println("Error Resolution: " + sms.getErrorResolution() + "\n");
48. }
49. }50.}

 
Didn't find what you were looking for? Find more on send sms programme Or get search suggestion and latest updates.




Tagged: