国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

利用Jmail發帶附件的郵件

2019-11-18 11:33:49
字體:
來源:轉載
供稿:網友

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



發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 定远县| 汉沽区| 韩城市| 淮安市| 方山县| 五峰| 改则县| 台州市| 景泰县| 万载县| 新龙县| 七台河市| 肇庆市| 新田县| 冷水江市| 曲阳县| 高平市| 沾益县| 怀化市| 志丹县| 漳平市| 东台市| 巫山县| 平利县| 泸水县| 讷河市| 汝城县| 紫阳县| 洛南县| 红河县| 罗山县| 富平县| 鹤壁市| 雷州市| 宁乡县| 林西县| 镶黄旗| 老河口市| 洪雅县| 全州县| 枣庄市|