java从腾讯邮箱获得文件

package com.jack.platformweb.email.service;

import com.sun.mail.imap.IMAPStore;
import com.jack.common.redis.service.RedisService;
import com.jack.common.utils.DateUtils;
import com.jack.common.utils.JsonUtils;
import com.jack.common.utils.ZipUtils;
import com.jack.db.urgerobot.robot.model.RobotInfo;
import com.jack.platformweb.partner.service.GzOutUrgeFileService;
import com.jack.platformweb.robot.service.RobotInfoService;
import net.lingala.zip4j.exception.ZipException;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import javax.mail.*;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeUtility;
import javax.print.DocFlavor;
import java.io.*;
import java.util.*;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @Description
 * @Author zhenghao
 * @Date 2021/8/17 22:07
 **/
@Service
public class RemoteEmailService {

    private static Logger log = LoggerFactory.getLogger(RemoteEmailService.class);

    @Value("${gz.local.path}")
    private String attachFilePath;
    @Autowired
    private GzOutUrgeFileService gzOutUrgeFileService;
    @Autowired
    private RobotInfoService robotInfoService;
    @Autowired
    private RedisService redisService;

    //从哪个邮箱地址获取内容
    private static String username = "test@qq.com";
    private static String password = "123456";

    private static Integer robotId = 161;
    //过滤发件人
    private static List<String> monitoringEmail = Stream.of("tt@qq.com").collect(Collectors.toList());

    private IMAPStore getConnect() {
        log.info("开始获得邮件链接");
        // 准备连接服务器的会话信息
        IMAPStore store = null;
        try {
            Properties props = new Properties();
//            props.setProperty("mail.store.protocol", "imap");
//            props.setProperty("mail.imap.host", "imap.exmail.qq.com");
//            props.setProperty("mail.imap.port", "993");
//            props.setProperty("mail.imap.ssl.enable", "true");
//
//            props.setProperty("mail.imap.auth.plain.disable", "true");
//
//            Session session = Session.getInstance(props, new javax.mail.Authenticator() {
//                @Override
//
//                protected PasswordAuthentication getPasswordAuthentication() {
//                    return new PasswordAuthentication(username, password
//
//                    );
//
//                }
//
//            });
            props.put("mail.imap.host", "imap.exmail.qq.com");//QQ邮箱为:imap.qq.com
            props.put("mail.imap.auth", "true");
            props.setProperty("mail.st
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

g-Jack

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值