I am new to java programming. I have used smsj api to send messages from pc to mobile through a gsm modem. I have succesfully been able to send plain text messages using SmsSender.sendTextSms(msg, reciever, sender)
as well as unicode messages using SmsSender.sendUnicodeTextSms("smsj हिन्दी मेसेज", reciever);
.
They say it supports EMS messages too. I am trying to send picture messages (black and white), and audio clips through this. But i cannot figure out how to do this.
The documentation shows that there is a class EmsMessage
that implements SmsMessage
But i couldn't find any details on how to use it. I have also gone through its forum but again cant find any solution.
Hoping someone could guide me on this.
this is my code for sending text messages..
public class SendMessage {
public void send() {
try{
SmsSender smsSender = SmsSender.getGsmSender("COM14");
String msg ="smsj test message";
String reciever = "919790968633";
String sender ="919176968289";
smsSender.connect();
smsSender.sendTextSms(msg, reciever, sender); //simple text message
smsSender.sendUnicodeTextSms("smsj हिन्दी मेसेज", reciever); //unicode message
smsSender.disconnect();
} catch(IOException i){
i.printStackTrace();
System.out.println("i");
} catch(SmsException s){
s.printStackTrace();
System.out.println("s");
}
}
public static void main(String args[]){
SendMessage app = new SendMessage();
app.send();
}
}
i tried this code for sending ems message.. but it seems to be wrong.
EmsMessage ems = new EmsMessage();
ems.addText(msg);
SmsMessage sms ;
sms=ems;
smsSender.sendSms(sms, reciever, sender);
i get this error message:
60 [main] INFO org.marre.sms.transport.gsm.SerialComm - >> AT+CMGF=0
261 [main] INFO org.marre.sms.transport.gsm.SerialComm - <<
261 [main] INFO org.marre.sms.transport.gsm.SerialComm - << OK
Exception in thread "main" java.lang.NullPointerException
at org.marre.sms.transport.gsm.GsmTransport.send(GsmTransport.java:175)
at org.marre.SmsSender.sendSms(SmsSender.java:551)
at org.marre.SendMessage.send(SendMessage.java:44)
at org.marre.SendMessage.main(SendMessage.java:58)
Can anyone help me what is the correct syntax of using this EmsMessage and SmsMessage class?
http://smsj.sourceforge.net/apidocs/org/marre/sms/ems/EmsMessage.html here you have needed documentation
addElement should add graphics, movies etc..
addText this should add text
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With