Changes

Jump to: navigation, search
no edit summary
9.1 Lets first add the api which we will need for the email functionality
<presource lang="java">
import net.rim.blackberry.api.mail;
</presource>
9.2 In order to add send email functionality to our application, we must have the appropriate menu option in our application.
<presource lang="java">
// Email selected student
MenuItem emailStudent = new MenuItem(new StringProvider("Email Student"), 500, 5);
));
</presource>
9.3 Now lets get the students email address and name
<presource lang="java">
Student student = (Student) _keywordFilterField.getSelectedElement();
String studentEmail = student.getEmail();
String studentName = student.getname();
</presource>
9.4 Now we must set up a new message and content. Here we create a new message in the SENT folder of the device and fill it with a predefined body
<presource lang="java">
Store store = Session.getDefaultInstance().getStore();
Folder sentFolder = store.list(Folder.SENT);
//send the message
Transport.send(msg);
</presource>
9.5 Lets catch any exceptions and notify the user if the message was sent.
<presource lang="java">
catch (Exception me) {
System.err.println(me);
Dialog.alert(studentName + " has been emailed!");
</presource>
1
edit

Navigation menu