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());