package com.sidiw.util.jmail;
import Java.util.Date;
import java.util.HashMap;
import java.util.Map;
import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.activation.FileDataSource;
import javax.mail.MessagingException;
import javax.mail.Multipart;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import javax.mail.internet.MimeMessage.RecipientType;
import sun.misc.BASE64Encoder;
public class SendMail {
/** 文本编码 */
private String encode;
/** 文本还是Html内容 */
private boolean HTML;
private Session session;
private Transport transport;
private BASE64Encoder enc = new sun.misc.BASE64Encoder();
public SendMail() {
this.encode = "GBK";
this.HTML = true;
}
public SendMail(String encode, boolean html) {
this.encode = encode;
this.HTML = html;
}
public boolean connect(String smtpHost, String uid, String pwd) {
boolean result = false;
ConnectMail connect = new ConnectMail();
result = connect.connectSmtp(smtpHost, uid, pwd);
this.session = connect.getSession();
this.transport = connect.getTransport();
return result;
}
public void close() {
if (this.transport != null) {
try {
this.transport.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}