Search This Blog

Tuesday, 1 January 2013

send SMS via code - Blackberry

Hello friends,
                    Here is the simplest way to send an SMS from your app automatically....in Blackberry. :)




CODE:


String _no = "122344556767";
String _msg = "hello this is a test SMS.";
DatagramConnection _dc = null;
String _openString = "sms://";

try{
_dc = (DatagramConnection)Connector.open(_openString);
byte[] data = _msg.getBytes();
Datagram d = _dc.newDatagram(_dc.getMaximumLength());
d.setAddress("//"+_no);
_dc.send(d);

}catch(Exception e){

}

How to send Email from your app in Blackberry

Hello friends,
                     Here is the code for sending automated  email from your blackberry App :)


CODE:


Message msg = new Message();
Address receipients[] = new Address[1];
try{
receipients[0] = new Address("user@abc.com","user");//two paramters i .e email id and name.
msg.addRecipients(Message.RecipientType.TO, receipients);

msg.setSubject("Testing subject");
msg.setContent("This is a test mail.");
msg.setPriority(Message.Priority.HIGH);
Transport.send(msg);


}catch(Exception e){

System.out.println("Error: "+e.toString());

}


Regards.