0

嗨朋友们,我使用下面的代码发送邮件。我在 JDE5.0 中使用 ESS 对其进行了测试,但它不起作用。所以请给我一些解决方案。

导入 net.rim.blackberry.api.mail。; 导入 net.rim.blackberry.api.mail.event。; 导入 net.rim.device.api.system.*;公共类 BasicMail 扩展应用程序 { 私人商店商店;static void main (String args[]) { BasicMail app = new BasicMail("a"); app.enterEventDispatcher(); } BasicMail(String s) { //从默认邮件Session中获取Store。Store store = Session.getDefaultInstance().getStore();

//检索发送的文件夹 Folder[] folder = store.list(Folder.SENT); 文件夹 sentfolder = 文件夹 [0];

//创建一条新消息并将其存储在已发送的文件夹中 Message msg = new Message(sentfolder); 地址收件人[] = 新地址[1];

尝试{收件人[0]=新地址(“poovavin@gmail.com”,“poovannan”);

  //add the recipient list to the message
  msg.addRecipients(Message.RecipientType.TO, recipients);

  //set a subject for the message
  msg.setSubject("Test email");

  //sets the body of the message
  msg.setContent("This is a test email from my BlackBerry Wireless Handheld");

  //sets priority
  msg.setPriority(Message.Priority.HIGH);

  //send the message
  Transport.send(msg);

} 捕捉(例外我){ System.err.println(我); } }

}

4

1 回答 1

0

请访问以下链接,这将对您有所帮助。

http://www.codinguru.com/2011/08/sending-email-with-attachment-in.html

于 2011-08-05T11:15:15.597 回答