import Java.io.*;
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
/**
* <p>Title: 简易MailBean</p>
* <p>Description: 提供简便的Mail发送功能(/p>
* <p>Copyright: Copyright (c) 2003</p>
* @version 1.0
*/
class ExtendString {
public ExtendString() {
}
/**
去掉字符串两端的空白字符,并将字符串转化为中国的标准字符gb2312的字符串.
*/
public String CS(String str) { //去掉字符串2端的空白字符
try {
if (str == null)
return "";
str = str.trim();
if (str == null)
return "";
str = new String(str.getBytes("8859_1"), "GBK");
}
catch (Exception e) {
System.out.println(e);
}
return str;
}
}
public class SendMail
{
private String errMsg = "";
private ExtendString ExStr = new ExtendString();
private String sender = "";//发件人地址
private String smtpHost = "";//邮件发送服务器(smtp)
private String user = ""; //登录用户名
private String passWord = "";//登录密码
private String subject = "";//mail主题
public SendMail()
{
this.setPropertiesAttri();
}
private void setPropertiesAttri()
{
try
{
InputStream is = getClass().getResourceAsStream("MailServer.properties");
Properties prop = new Properties();
prop.load(is);
this.setSmtpHost(prop.get("SmtpHost").toString());