首页 新闻 会员 周边 捐助

Javamail邮件同步到本地outlook客户端

0
悬赏园豆:80 [待解决问题]

近期项目中用到了javamail发送邮件的功能,具体功能就是JSP页面写了一个邮件发送功能,类似outlook的客户端,邮件可以正常发送,但用户希望实现在系统中发送的邮件能同步到用户outlook客户端的【已发邮件】文件夹中,一直没有找到解决方法,邮箱服务器是用户公司的基于exchange的服务器,还希望各位大神给个思路。

iscfsw的主页 iscfsw | 初学一级 | 园豆:74
提问于:2015-12-30 16:31
< >
分享
所有回答(1)
0

package com.mail;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.Date;
import java.util.Properties;
import javax.mail.Message;
import javax.mail.Session;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeUtility;
/**

  • @说明 保存一个邮件
  • @author cuisuqiang
  • @version 1.0
  • @since
    /
    public class TextMail {
    public static void main(String[] args) throws Exception {
    Properties props = new Properties();
    props.put( "mail.smtp.host ", "smtp.163.com ");
    props.put("mail.smtp.port", 25);
    props.put("mail.smtp.auth", "true");
    Session session = Session.getInstance(props);
    session.setDebug(true);
    Message message = new MimeMessage(session);
    InternetAddress from = new InternetAddress("test20120711120200@163.com");
    from.setPersonal(MimeUtility.encodeText("java小强test20120711120200@163.com"));
    message.setFrom(from);
    InternetAddress to = new InternetAddress("test20120711120200@163.com");
    message.setRecipient(Message.RecipientType.TO, to);
    message.setSubject(MimeUtility.encodeText("强哥邀请,谁敢不从!"));
    message.setText("强哥邀请你访问我的博客:http://cuisuqiang.iteye.com/!");
    message.setSentDate(new Date());
    // 邮件对象
    File file = new File("C:\textmail.eml");
    // 获得输出流
    OutputStream ips = new FileOutputStream(file);
    // 把邮件内容写入到文件
    message.writeTo(ips);
    // 关闭流
    ips.close();
    System.out.println("发送完毕");
    }
    }
    package com.mail;
    import java.io.File;
    import java.io.FileOutputStream;
    import java.io.OutputStream;
    import java.util.Date;
    import java.util.Properties;
    import javax.mail.Message;
    import javax.mail.Session;
    import javax.mail.internet.InternetAddress;
    import javax.mail.internet.MimeMessage;
    import javax.mail.internet.MimeUtility;
    /
    *
  • @说明 保存一个邮件
  • @author cuisuqiang
  • @version 1.0
  • @since
    */
    public class TextMail {
    public static void main(String[] args) throws Exception {
    Properties props = new Properties();
    props.put( "mail.smtp.host ", "smtp.163.com ");
    props.put("mail.smtp.port", 25);
    props.put("mail.smtp.auth", "true");
    Session session = Session.getInstance(props);
    session.setDebug(true);
    Message message = new MimeMessage(session);
    InternetAddress from = new InternetAddress("test20120711120200@163.com");
    from.setPersonal(MimeUtility.encodeText("java小强test20120711120200@163.com"));
    message.setFrom(from);
    InternetAddress to = new InternetAddress("test20120711120200@163.com");
    message.setRecipient(Message.RecipientType.TO, to);
    message.setSubject(MimeUtility.encodeText("强哥邀请,谁敢不从!"));
    message.setText("强哥邀请你访问我的博客:http://cuisuqiang.iteye.com/!");
    message.setSentDate(new Date());
    // 邮件对象
    File file = new File("C:\textmail.eml");
    // 获得输出流
    OutputStream ips = new FileOutputStream(file);
    // 把邮件内容写入到文件
    message.writeTo(ips);
    // 关闭流
    ips.close();
    System.out.println("发送完毕");
    }
    }
黑蛮 | 园豆:206 (菜鸟二级) | 2021-10-10 11:06
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册