如何在blackberry eclipse插件1.1中测试发送电子邮件
嗨朋友们,我使用下面的代码发送邮件。 我在JDE5.0中用ESS测试过它不起作用。 所以请给我一些解决方案。
导入 net.rim.blackberry.api.mail.; 导入net.rim.blackberry.api.mail.event。; 导入 net.rim.device.api.system.*; 公共类BasicMail扩展应用程序{ 私人商店; 静态无效主(字符串参数[]){ BasicMail 应用程序 = new BasicMail("a"); app.enterEventDispatcher(); } 基本邮件(字符串) { //从默认邮件会话中获取Store。 商店 store = Session.getDefaultInstance().getStore();
//获取发送的文件夹 文件夹[]文件夹= store.list(Folder.SENT); 文件夹 sendfolder = 文件夹[0];
//创建一条新消息并将其存储在已发送文件夹中 消息 msg = 新消息(sentfolder); 地址收件人[] = 新地址[1];
尝试 { 收件人[0]= 新地址("[电子邮件受保护]", "波瓦南”);
//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(me); } }
}
Hi friends I usedthe code below for sending mail.
I tested it in JDE5.0 with ESS it doesnt work.
So please give me some solution.
import net.rim.blackberry.api.mail.;
import net.rim.blackberry.api.mail.event.;
import net.rim.device.api.system.*;
public class BasicMail extends Application {
private Store store;
static void main (String args[]) {
BasicMail app = new BasicMail("a");
app.enterEventDispatcher();
}
BasicMail(String s)
{
//Get the Store from the default mail Session.
Store store = Session.getDefaultInstance().getStore();
//retrieve the sent folder
Folder[] folders = store.list(Folder.SENT);
Folder sentfolder = folders[0];
//create a new message and store it in the sent folder
Message msg = new Message(sentfolder);
Address recipients[] = new Address[1];
try {
recipients[0]= new Address("[email protected]", "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);
}
catch (Exception me) {
System.err.println(me);
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请访问下面的链接,这会对您有所帮助。
http://www.codinguru.com/2011/08 /sending-email-with-attachment-in.html
Visit this below link this will help you.
http://www.codinguru.com/2011/08/sending-email-with-attachment-in.html