|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
最初被命名为Oak,目标设定在家用电器等小型系统的编程语言,来解决诸如电视机、电话、闹钟、烤面包机等家用电器的控制和通讯问题。 /*
*Author:tyfun
*DateTime:2003.01.09
*Package:com.westarsoft.function
*/
packagecom.westarsoft.function;
importjava.util.*;
importjava.io.*;
importjavax.mail.*;
importjavax.mail.internet.*;
importjavax.activation.*;
publicclassSendMail{
privateStringSMTPServer=newString();
privateStringfrom=newString();
privateStringsubject=newString();
privateStringcontent=newString();
privateStringuser=newString();
privateStringpassword=newString();
publicStringgetSMTPServer(){
returnSMTPServer;
}
publicvoidsetSMTPServer(StringSMTPServer){
this.SMTPServer=SMTPServer;
}
publicStringgetFrom(){
returnfrom;
}
publicvoidsetFrom(Stringfrom){
this.from=from;
}
publicStringgetSubject(){
returnsubject;
}
publicvoidsetSubject(Stringsubject){
this.subject=subject;
}
publicStringgetContent(){
returncontent;
}
publicvoidsetContent(Stringcontent){
this.content=content;
}
publicStringgetUser(){
returnuser;
}
publicvoidsetUser(Stringuser){
this.user=user;
}
publicStringgetPassword(){
returnpassword;
}
publicvoidsetPassword(Stringpassword){
this.password=password;
}
publicvoidsendMailTo(Stringto){
try{
Propertiesprops=newProperties();
SessionsendMailSession;
Storestore;
Transporttransport;
sendMailSession=Session.getInstance(props,null);
props.put("mail.smtp.host",SMTPServer);
MimeMessagenewMessage=newMimeMessage(sendMailSession);
newMessage.setFrom(newInternetAddress(from));
newMessage.setSubject(subject);
newMessage.setSentDate(newDate());
newMessage.setText(content);
StringTokenizertoken=newStringTokenizer(to,",");
InternetAddress[]addrArr=newInternetAddress[token.countTokens()];
inti=0;
while(token.hasMoreTokens()){
addrArr[i]=newInternetAddress(token.nextToken().toString());
i++;
}
transport=sendMailSession.getTransport("smtp");
transport.connect(SMTPServer,user,password);
newMessage.setRecipients(Message.RecipientType.TO,addrArr);
transport.send(newMessage);
}
catch(Exceptione){
System.out.println(e);
}
}
/*
publicstaticvoidmain(String[]args){
SendMailmail=newSendMail();
mail.setSMTPServer("200.1.1.157");
mail.setUser("lint");
mail.setPassword("30320");
mail.setFrom("lint@westar.com");
mail.setSubject("测试");
mail.setContent("test");
mail.sendMailTo("lint@westar.com,zouy@westar.com,zhangp@westar.com");
}
*/
}
Java编译的是字节码,跟C++相反,启动不够快,效率不够高,难以精确控制内存,但是优点是编程比C++容易,代码比较安全但是容易留下性能隐患,跨平台靠字节码在各个平台复制(一处编译到处调试) |
|