|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
自己的整个学习思路完全被老师的讲课思路所牵制,这样几节课听下来,恐怕自己的见解都应该是书里的知识点了,根本谈不上自身发现问题,分析问题,和解决问题能力的切实提高。
SimpleSendMessage.java
importjava.util.*;
importjavax.mail.*;
importjavax.mail.internet.*;
importjavax.activation.*;
publicclassSimpleSendMessage{
publicstaticvoidmain(String[]args){
//Collectthenecessaryinformationtosendasimplemessage
//Makesuretoreplacethevaluesforhost,to,andfromwith
//validinformation.
//host-mustbeavalidsmtpserverthatyoucurrentlyhave
//accessto.
//to-whoeverisgoingtogetyouremail
//from-whoeveryouwanttobe.Justrememberthatmanysmtp
//serverswillvalidatethedomainofthefromaddress
//beforeallowingthemailtobesent.
Stringhost="server.myhost.com";
Stringto="YourFriend@somewhere.com";
Stringfrom="MeMeMe@myhost.com";
Stringsubject="JSPRules!";
StringmessageText="Iamsendingamessageusingthe"
+"JavaMailAPI.
IcanincludeanytextthatIwant.";
booleansessionDebug=false;
//CreatesomepropertiesandgetthedefaultSession.
Propertiesprops=System.getProperties();
props.put("mail.host",host);
props.put("mail.transport.protocol","smtp");
Sessionsession=Session.getDefaultInstance(props,null);
//SetdebugontheSessionsowecanseewhatisgoingon
//Passingfalsewillnotechodebuginfo,andpassingtrue
//will.
session.setDebug(sessionDebug);
try{
//InstantiateanewMimeMessageandfillitwiththe
//requiredinformation.
Messagemsg=newMimeMessage(session);
msg.setFrom(newInternetAddress(from));
InternetAddress[]address={newInternetAddress(to)};
msg.setRecipients(Message.RecipientType.TO,address);
msg.setSubject(subject);
msg.setSentDate(newDate());
msg.setText(messageText);
//Handthemessagetothedefaulttransportservice
//fordelivery.
Transport.send(msg);
}
catch(MessagingExceptionmex){
mex.printStackTrace();
}
}
}
再说第三点:我并没有提到服务器也要整合,然后是IDE,一个好的IDE能够200%提高开发的速度,就说图形方面:你是经过简单托拽和点击就能实现功能好那。 |
|