|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
但是一些大型开发或者是保密型比较高的项目都会用java,原因有2点,一:java是开源的,不怕别人留后门,偷我工具,.net就不一样了,保持微软的一向风格,源代码不公开js|发送邮件
vishal_donthgavethisresponseon10/18/2000:
//thesearethepakagestobeimportedfrom
//JavaMail
//TheJavaMailPAckageeitherbedowloaded
//seperately
//orelseisAvailableintheJ2sdkee1.2
//(JavaEnterpriseEdition)
importjavax.mail.*;
importjavax.mail.internet.*;
importjava.util.*;
//Thisfunctioncanbeusedtosendthemail
//withtheparametersgiventoit
//Uhavetospecifythesmtpserverthrough
//whichuhavetosendthemail
//sinceiwastryingwithahomenetmail
//accountidirectlysentthemailitsserver
//Forsendingthismailuneedamailserver
//whichletsutorelaythemessages
//Trythisthingforsendingtoa
//www.homenetmail.comaccountbecauseitlets
//usend
//mailstotheaccountslikeexampletry
//sendingittoa"abc@homenetmail.com"
//account.Createthemailaccountinhomenet
//mailfirst.Ifugetanyotherserverwhich
//supportsrelayingucantrythisonthat
//also.
//UsethisfunctioninurServlettosend
//mailbycallingthefunctionwiththe
//parameters
publicvoidsendMail(StringtoAddr,Stringsubject,Stringbody,StringfromAddr)throwsRemoteException{
try{
Propertiesprops=newProperties();
props.put("mail.smtp.host","mail.homenetmail.com");
//HerewespecifytheSMTPserverthrough
//whichthemailshouldbedelivered
Sessionsession=Session.getDefaultInstance(props,null);
Messagemsg=newMimeMessage(session);
msg.setFrom(newInternetAddress(fromAddr));
//SpecifytheFromAddress
InternetAddress[]tos=InternetAddress.parse(toAddr);
//SpecifytheToAddress
msg.setRecipients(Message.RecipientType.TO,tos);
msg.setSubject(subject);
//SpecifytheSubject
msg.setText(body);
//SpecifytheBody
Transport.send(msg);
System.out.println("MessageisSent");
}
catch(Exceptione){
System.out.println(e);
}
}
//Uhavetorunthisfunctiononacomputer
//whichisdirectlyconnected
//tointernetbutnotthrougha
//proxy......orelseuseaproxywhich
//supportsSMTP
关于第二点:俺问问你,如果是企业级项目的话,诸如RMI,EJB,等一些关键技术,这些难道都不需要学么?如果光是使用jsp,servlet,javabean的话。 |
|