如何从黑莓应用程序发送 smtp 电子邮件

how to send smtp email from blackberry app

您好,我想使用 java 和 javax 从我的黑莓应用程序发送 smtp 电子邮件,我已经使用 javax 从我的 android 应用程序发送 smtp 电子邮件邮件像这样的代码:

  MimeMessage message = new MimeMessage(session);   
    DataHandler handler = new DataHandler(new ByteArrayDataSource(body.getBytes(), "text/plain"));   
    message.setSender(new InternetAddress(sender));   
    message.setSubject(subject);   
    message.setDataHandler(handler);   
    if (recipients.indexOf(',') > 0)   
        message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(recipients));   
    else  
        message.setRecipient(Message.RecipientType.TO, new InternetAddress(recipients));   
    Transport.send(message);

是否有类似的代码可以在黑莓应用程序中使用来发送 smtp 电子邮件?

试试这个-

Store store = Session.getDefaultInstance().getStore();
Folder[] folder = store.list(Folder.SENT);
Folder sent = folder[0];
Message msg = new Message(sent);
Address receipent[] = new Address[1];
 try
  {
    receipent[0] = new Address(To_Address, name);
                         msg.addRecipients(Message.RecipientType.TO, receipent);
                         msg.setSubject("Test Mail");
                         msg.setContent("This mail is to remind you that programmatically we can send the mail");
                         msg.setPriority(Priority.HIGH);
                         Transport.send(msg);
                 }

   catch (Exception e)
        {
               e.printStackTrace();
          }