Blackberry JAVA DEVELOPMENT ENVIRONMENT - - CRYPTOGRAPHIC SMART CARD DRIVER - DEVELOPMENT GUIDE Anleitung zur Fehlerbehebung Seite 157

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 286
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 156
157
10: Using the messages application
Reply to a message
Add the recipients. 1. Invoke Message.addRecipients() and provide the type of recipient (TO, CC, or BCC) and
the array of addresses to add as parameters to the method. If the message has multiple types of
recipients, invoke
addRecipients() once for each recipient type.
msg.addRecipients(Message.RecipientType.TO, toList);
Specify the name and email address of
the sender.
>Invoke setFrom(Address).
Address from = new Address("scott.mcph[email protected]", "Scott
McPherson");
msg.setFrom(from);
Add a subject line. >Invoke setSubject(String).
msg.setSubject("Test Message");
Specify the message contents. >Invoke setContent(String). Typically, the application retrieves content from text that a
BlackBerry® device user types in a field.
try {
msg.setContent("This is a test message.");
} catch(MessagingException e) {
System.out.println(e.getMessage());
}
Send the message. >Invoke Transport.send(Message). The Transport object represents the messaging
transport protocol.
try {
Transport.send(msg);
} catch(MessagingException e) {
System.out.println(e.getMessage());
}
Task Steps
Reply to a message. >Invoke Message.reply(Boolean). As a parameter to this method, specify true to reply to all
message recipients or false to reply to only the sender.
Store store = Session.waitForDefaultSession().getStore();
Folder[] folders = store.list(INBOX);
Folder inbox = folders[0];
Message[] messages = folder.getMessages();
if( messages.length > 0 ) {
Message msg = messages[0];
}
Message reply = msg.reply(true);
Transport.send(reply);
Task Steps
Seitenansicht 156
1 2 ... 152 153 154 155 156 157 158 159 160 161 162 ... 285 286

Kommentare zu diesen Handbüchern

Keine Kommentare