导航:首页 > 编程语言 > java邮件回执

java邮件回执

发布时间:2022-09-28 10:55:25

javamail如何读取回执信息

请在OUTLOOK中选中工具再选中选项,打开选项后出现首选参数栏选中电子邮件选项再选择跟踪选项,内面有具体的设置选项,可测试一下即可

Ⅱ java发送邮件程序如何验证邮件是否发送失败

public boolean sendout()
{
try
{
mimeMessage.setContent(mp);
mimeMessage.saveChanges();
Session mailSession = Session.getInstance(props, null);
Transport transport = mailSession.getTransport("smtp");
transport.connect(hostname, username, password);
transport.sendMessage(mimeMessage, mimeMessage.getRecipients(javax.mail.Message.RecipientType.TO));
transport.close();
}
catch(Exception e)
{

e.printStackTrace();
return false;
}
return true;
}

捕获异常判断

Ⅲ java mail 问题:系统给用户发送了提醒信息,怎么在系统后台获取用户的回执信息。

没有做过,但是经常看到这种例子,个人认为可以这么做:
按钮 就是一个<a>连接,直接向一个servlet 发请求,带上用户id 和标志就可以了
如果让我实现,思路就是这样

Ⅳ javamail接收邮件怎么解析内容

package com.ghy.util;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Properties;

import javax.mail.BodyPart;
import javax.mail.Flags;
import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Multipart;

import javax.mail.Part;
import javax.mail.Session;
import javax.mail.Store;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeUtility;

public class PraseMimeMessage{
private MimeMessage mimeMessage=null;
private String saveAttachPath="";//附件下载后的存放目录
private StringBuffer bodytext=new StringBuffer();
//存放邮件内容的StringBuffer对象
private String dateformat="yy-MM-ddHH:mm";//默认的日前显示格式
/**
*构造函数,初始化一个MimeMessage对象
*/
public PraseMimeMessage() {
}
public PraseMimeMessage(MimeMessage mimeMessage) {
this.mimeMessage=mimeMessage;
}
public void setMimeMessage(MimeMessage mimeMessage){
this.mimeMessage=mimeMessage;
}
/**
*获得发件人的地址和姓名
*/
public String getFrom1()throws Exception{
InternetAddress address[]=(InternetAddress[])mimeMessage.getFrom();
String from=address[0].getAddress();
if(from==null){
from="";
}
String personal=address[0].getPersonal();
if(personal==null){
personal="";
}
String fromaddr=personal+"<"+from+">";
return fromaddr;
}
/**
*获得邮件的收件人,抄送,和密送的地址和姓名,根据所传递的参数的不同
*"to"----收件人"cc"---抄送人地址"bcc"---密送人地址
* @throws Exception */
public String getMailAddress(String type){
String mailaddr="";
try {
String addtype=type.toUpperCase();
InternetAddress []address=null;
if(addtype.equals("TO")||addtype.equals("CC")||addtype.equals("BBC")){
if(addtype.equals("TO")){
address=(InternetAddress[])mimeMessage.getRecipients(Message.RecipientType.TO);
}
else if(addtype.equals("CC")){
address=(InternetAddress[])mimeMessage.getRecipients(Message.RecipientType.CC);
}
else{
address=(InternetAddress[])mimeMessage.getRecipients(Message.RecipientType.BCC);
}
if(address!=null){
for (int i = 0; i < address.length; i++) {
String email=address[i].getAddress();
if(email==null)email="";
else{
email=MimeUtility.decodeText(email);
}
String personal=address[i].getPersonal();
if(personal==null)personal="";
else{
personal=MimeUtility.decodeText(personal);
}
String compositeto=personal+"<"+email+">";
mailaddr+=","+compositeto;
}
mailaddr=mailaddr.substring(1);
}
}
else{
}
} catch (Exception e) {
// TODO: handle exception
}
return mailaddr;
}
/**
*获得邮件主题
*/
public String getSubject()
{
String subject="";
try {
subject=MimeUtility.decodeText(mimeMessage.getSubject());
if(subject==null)subject="";
} catch (Exception e) {
// TODO: handle exception
}
return subject;
}
/**
*获得邮件发送日期
*/
public String getSendDate()throws Exception{
Date senddate=mimeMessage.getSentDate();
SimpleDateFormat format=new SimpleDateFormat(dateformat);
return format.format(senddate);
}
/**
*解析邮件,把得到的邮件内容保存到一个StringBuffer对象中,解析邮件
*主要是根据MimeType类型的不同执行不同的操作,一步一步的解析
*/
public void getMailContent(Part part)throws Exception{
String contenttype=part.getContentType();
int nameindex=contenttype.indexOf("name");
boolean conname=false;
if(nameindex!=-1)conname=true;
if(part.isMimeType("text/plain")&&!conname){
bodytext.append((String)part.getContent());
}else if(part.isMimeType("text/html")&&!conname){
bodytext.append((String)part.getContent());
}
else if(part.isMimeType("multipart/*")){
Multipart multipart=(Multipart)part.getContent();
int counts=multipart.getCount();
for(int i=0;i<counts;i++){
getMailContent(multipart.getBodyPart(i));
}
}else if(part.isMimeType("message/rfc822")){
getMailContent((Part)part.getContent());
}
else{}
}
/**
*获得邮件正文内容
*/
public String getBodyText(){
return bodytext.toString();
}
/**
*判断此邮件是否需要回执,如果需要回执返回"true",否则返回"false"

* @throws MessagingException */
public boolean getReplySign() throws MessagingException{
boolean replysign=false;
String needreply[]=mimeMessage.getHeader("Disposition-Notification-To");
if(needreply!=null){
replysign=true;
}
return replysign;
}
/**
*获得此邮件的Message-ID
* @throws MessagingException */
public String getMessageId() throws MessagingException{
return mimeMessage.getMessageID();
}

/**
*【判断此邮件是否已读,如果未读返回返回false,反之返回true】
* @throws MessagingException */
public boolean isNew() throws MessagingException{
boolean isnew =false;
Flags flags=((Message)mimeMessage).getFlags();
Flags.Flag[]flag=flags.getSystemFlags();
for (int i = 0; i < flag.length; i++) {
if(flag[i]==Flags.Flag.SEEN){
isnew=true;
break;
}
}
return isnew;
}
/**
*判断此邮件是否包含附件
* @throws MessagingException */
public boolean isContainAttach(Part part) throws Exception{
boolean attachflag=false;
String contentType=part.getContentType();
if(part.isMimeType("multipart/*")){
Multipart mp=(Multipart)part.getContent();
//获取附件名称可能包含多个附件
for(int j=0;j<mp.getCount();j++){
BodyPart mpart=mp.getBodyPart(j);
String disposition=mpart.getDescription();
if((disposition!=null)&&((disposition.equals(Part.ATTACHMENT))||(disposition.equals(Part.INLINE)))){
attachflag=true;
}else if(mpart.isMimeType("multipart/*")){
attachflag=isContainAttach((Part)mpart);
}else{
String contype=mpart.getContentType();
if(contype.toLowerCase().indexOf("application")!=-1) attachflag=true;
if(contype.toLowerCase().indexOf("name")!=-1) attachflag=true;
}
}
}else if(part.isMimeType("message/rfc822")){
attachflag=isContainAttach((Part)part.getContent());
}
return attachflag;
}
/**
*【保存附件】
* @throws Exception
* @throws IOException
* @throws MessagingException
* @throws Exception */
public void saveAttachMent(Part part) throws Exception {
String fileName="";
if(part.isMimeType("multipart/*")){
Multipart mp=(Multipart)part.getContent();
for(int j=0;j<mp.getCount();j++){
BodyPart mpart=mp.getBodyPart(j);
String disposition=mpart.getDescription();
if((disposition!=null)&&((disposition.equals(Part.ATTACHMENT))||(disposition.equals(Part.INLINE)))){
fileName=mpart.getFileName();
if(fileName.toLowerCase().indexOf("GBK")!=-1){
fileName=MimeUtility.decodeText(fileName);
}
saveFile(fileName,mpart.getInputStream());
}
else if(mpart.isMimeType("multipart/*")){
fileName=mpart.getFileName();
}
else{
fileName=mpart.getFileName();
if((fileName!=null)){
fileName=MimeUtility.decodeText(fileName);
saveFile(fileName,mpart.getInputStream());
}
}
}
}
else if(part.isMimeType("message/rfc822")){
saveAttachMent((Part)part.getContent());
}
}
/**
*【设置附件存放路径】
*/
public void setAttachPath(String attachpath){
this.saveAttachPath=attachpath;
}

/**
*【设置日期显示格式】
*/
public void setDateFormat(String format){
this.dateformat=format;
}

/**
*【获得附件存放路径】
*/

public String getAttachPath()
{
return saveAttachPath;
}
/**
*【真正的保存附件到指定目录里】
*/
private void saveFile(String fileName,InputStream in)throws Exception{
String osName=System.getProperty("os.name");
String storedir=getAttachPath();
String separator="";
if(osName==null)osName="";
if(osName.toLowerCase().indexOf("win")!=-1){
//如果是window 操作系统
separator="/";
if(storedir==null||storedir.equals(""))storedir="c:\tmp";
}
else{
//如果是其他的系统
separator="/";
storedir="/tmp";
}
File strorefile=new File(storedir+separator+fileName);
BufferedOutputStream bos=null;
BufferedInputStream bis=null;
try {
bos=new BufferedOutputStream(new FileOutputStream(strorefile));
bis=new BufferedInputStream(in);
int c;
while((c=bis.read())!=-1){
bos.write(c);
bos.flush();
}
} catch (Exception e) {
// TODO: handle exception
}finally{
bos.close();
bis.close();
}
}
/**
*PraseMimeMessage类测试

* @throws Exception */
public static void main(String[] args) throws Exception {
String host="pop3.sina.com.cn";
String username="guohuaiyong70345";
String password="071120";
Properties props=new Properties();
Session session=Session.getDefaultInstance(props,null);
Store store=session.getStore("pop3");
store.connect(host,username,password);
Folder folder=store.getFolder("INBOX");
folder.open(Folder.READ_ONLY);
Message message[]=folder.getMessages();
PraseMimeMessage pmm=null;
for (int i = 0; i < message.length; i++) {
System.out.println("****************************************第"+(i+1)+"封邮件**********************************");
pmm=new PraseMimeMessage((MimeMessage)message[i]);
System.out.println("主题 :"+pmm.getSubject());
pmm.setDateFormat("yy年MM月dd日 HH:mm");
System.out.println("发送时间 :"+pmm.getSendDate());
System.out.println("是否回执 :"+pmm.getReplySign());
System.out.println("是否包含附件 :"+pmm.isContainAttach((Part)message[i]));
System.out.println("发件人 :"+pmm.getFrom1());
System.out.println("收件人 :"+pmm.getMailAddress("TO"));
System.out.println("抄送地址 :"+pmm.getMailAddress("CC"));
System.out.println("密送地址 :"+pmm.getMailAddress("BCC"));
System.out.println("邮件ID :"+i+":"+pmm.getMessageId());
pmm.getMailContent((Part)message[i]); //根据内容的不同解析邮件
pmm.setAttachPath("c:/tmp/mail"); //设置邮件附件的保存路径
pmm.saveAttachMent((Part)message[i]); //保存附件
System.out.println("邮件正文 :"+pmm.getBodyText());
System.out.println("*********************************第"+(i+1)+"封邮件结束*************************************");
}
}
}

Ⅳ javamail发送邮件怎么确定邮件是否成功了,会有回执信息返回吗,send()方法返回值是空。

通过捕捉异常来判断,看一下我写的代码
try{
transport.connect(smtp, username, password);
transport.sendMessage(message, message.getAllRecipients());
transport.close();
out.print("<script charset='utf-8'>alert('邮件发送已成功!');window.history.go(-1);</script>");
} catch (MessagingException e) {
// TODO Auto-generated catch block
out.print("<script charset='utf-8'>alert('邮件发送失败!');window.history.go(-1);</script>");
}
这样就可以判断是否发送成功了。
我最近也在做javamail的项目,欢迎来一起讨论。

Ⅵ Java做满意度评价 和打印回执单怎么写

用几个常量表示评价的等级,根据评价者的按键选择,显示相应的评价级别。并最终打印出来即可

Ⅶ javamail收发信件时,服务器,收发方的名称应该怎样设置才有效呢

package com.gwxc.hz.mail.demo;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Properties;

import javax.mail.BodyPart;
import javax.mail.Flags;
import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Multipart;
import javax.mail.NoSuchProviderException;
import javax.mail.Part;
import javax.mail.Session;
import javax.mail.Store;
import javax.mail.URLName;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeUtility;

public class ReciveOneMail {

/**
* 有一封邮件就需要建立一个ReciveMail对象
*/
private MimeMessage mimeMessage = null;
private String saveAttachPath = ""; // 附件下载后的存放目录
private StringBuffer bodytext = new StringBuffer();// 存放邮件内容
private String dateformat = "yy-MM-dd HH:mm"; // 默认的日前显示格式

public ReciveOneMail(MimeMessage mimeMessage) {
this.mimeMessage = mimeMessage;
}

public void setMimeMessage(MimeMessage mimeMessage) {
this.mimeMessage = mimeMessage;
}

/**
* 获得发件人的地址和姓名
*/
public String getFrom() throws Exception {
InternetAddress address[] = (InternetAddress[]) mimeMessage.getFrom();
String from = address[0].getAddress();
if (from == null)
from = "";
String personal = address[0].getPersonal();
if (personal == null)
personal = "";
String fromaddr = personal + "<" + from + ">";
return fromaddr;
}

/**
* 获得邮件的收件人,抄送,和密送的地址和姓名,根据所传递的参数的不同 "to"----收件人 "cc"---抄送人地址 "bcc"---密送人地址
*/
public String getMailAddress(String type) throws Exception {
String mailaddr = "";
String addtype = type.toUpperCase();
InternetAddress[] address = null;
if (addtype.equals("TO") || addtype.equals("CC")
|| addtype.equals("BCC")) {
if (addtype.equals("TO")) {
address = (InternetAddress[]) mimeMessage
.getRecipients(Message.RecipientType.TO);
} else if (addtype.equals("CC")) {
address = (InternetAddress[]) mimeMessage
.getRecipients(Message.RecipientType.CC);
} else {
address = (InternetAddress[]) mimeMessage
.getRecipients(Message.RecipientType.BCC);
}
if (address != null) {
for (int i = 0; i < address.length; i++) {
String email = address[i].getAddress();
if (email == null)
email = "";
else {
email = MimeUtility.decodeText(email);
}
String personal = address[i].getPersonal();
if (personal == null)
personal = "";
else {
personal = MimeUtility.decodeText(personal);
}
String compositeto = personal + "<" + email + ">";
mailaddr += "," + compositeto;
}
mailaddr = mailaddr.substring(1);
}
} else {
throw new Exception("Error emailaddr type!");
}
return mailaddr;
}

/**
* 获得邮件主题
*/
public String getSubject() throws MessagingException {
String subject = "";
try {
subject = MimeUtility.decodeText(mimeMessage.getSubject());
if (subject == null)
subject = "";
} catch (Exception exce) {
}
return subject;
}

/**
* 获得邮件发送日期
*/
public String getSentDate() throws Exception {
Date sentdate = mimeMessage.getSentDate();
SimpleDateFormat format = new SimpleDateFormat(dateformat);
return format.format(sentdate);
}

/**
* 获得邮件正文内容
*/
public String getBodyText() {
return bodytext.toString();
}

/**
* 解析邮件,把得到的邮件内容保存到一个StringBuffer对象中,解析邮件 主要是根据MimeType类型的不同执行不同的操作,一步一步的解析
*/
public void getMailContent(Part part) throws Exception {
String contenttype = part.getContentType();
int nameindex = contenttype.indexOf("name");
boolean conname = false;
if (nameindex != -1)
conname = true;
System.out.println("CONTENTTYPE: " + contenttype);
if (part.isMimeType("text/plain") && !conname) {
bodytext.append((String) part.getContent());
} else if (part.isMimeType("text/html") && !conname) {
bodytext.append((String) part.getContent());
} else if (part.isMimeType("multipart/*")) {
Multipart multipart = (Multipart) part.getContent();
int counts = multipart.getCount();
for (int i = 0; i < counts; i++) {
getMailContent(multipart.getBodyPart(i));
}
} else if (part.isMimeType("message/rfc822")) {
getMailContent((Part) part.getContent());
} else {
}
}

/**
* 判断此邮件是否需要回执,如果需要回执返回"true",否则返回"false"
*/
public boolean getReplySign() throws MessagingException {
boolean replysign = false;
String needreply[] = mimeMessage
.getHeader("Disposition-Notification-To");
if (needreply != null) {
replysign = true;
}
return replysign;
}

/**
* 获得此邮件的Message-ID
*/
public String getMessageId() throws MessagingException {
return mimeMessage.getMessageID();
}

/**
* 【判断此邮件是否已读,如果未读返回返回false,反之返回true】
*/
public boolean isNew() throws MessagingException {
boolean isnew = false;
Flags flags = ((Message) mimeMessage).getFlags();
Flags.Flag[] flag = flags.getSystemFlags();
System.out.println("flags's length: " + flag.length);
for (int i = 0; i < flag.length; i++) {
if (flag[i] == Flags.Flag.SEEN) {
isnew = true;
System.out.println("seen Message.......");
break;
}
}
return isnew;
}

/**
* 判断此邮件是否包含附件
*/
public boolean isContainAttach(Part part) throws Exception {
boolean attachflag = false;
String contentType = part.getContentType();
if (part.isMimeType("multipart/*")) {
Multipart mp = (Multipart) part.getContent();
for (int i = 0; i < mp.getCount(); i++) {
BodyPart mpart = mp.getBodyPart(i);
String disposition = mpart.getDisposition();
if ((disposition != null)
&& ((disposition.equals(Part.ATTACHMENT)) || (disposition
.equals(Part.INLINE))))
attachflag = true;
else if (mpart.isMimeType("multipart/*")) {
attachflag = isContainAttach((Part) mpart);
} else {
String contype = mpart.getContentType();
if (contype.toLowerCase().indexOf("application") != -1)
attachflag = true;
if (contype.toLowerCase().indexOf("name") != -1)
attachflag = true;
}
}
} else if (part.isMimeType("message/rfc822")) {
attachflag = isContainAttach((Part) part.getContent());
}
return attachflag;
}

/**
* 【保存附件】
*/
public void saveAttachMent(Part part) throws Exception {
String fileName = "";
if (part.isMimeType("multipart/*")) {
Multipart mp = (Multipart) part.getContent();
for (int i = 0; i < mp.getCount(); i++) {
BodyPart mpart = mp.getBodyPart(i);
String disposition = mpart.getDisposition();
if ((disposition != null)
&& ((disposition.equals(Part.ATTACHMENT)) || (disposition
.equals(Part.INLINE)))) {
fileName = mpart.getFileName();
if (fileName.toLowerCase().indexOf("gb2312") != -1) {
fileName = MimeUtility.decodeText(fileName);
}
saveFile(fileName, mpart.getInputStream());
} else if (mpart.isMimeType("multipart/*")) {
saveAttachMent(mpart);
} else {
fileName = mpart.getFileName();
if ((fileName != null)
&& (fileName.toLowerCase().indexOf("GB2312") != -1)) {
fileName = MimeUtility.decodeText(fileName);
saveFile(fileName, mpart.getInputStream());
}
}
}
} else if (part.isMimeType("message/rfc822")) {
saveAttachMent((Part) part.getContent());
}
}

/**
* 【设置附件存放路径】
*/

public void setAttachPath(String attachpath) {
this.saveAttachPath = attachpath;
}

/**
* 【设置日期显示格式】
*/
public void setDateFormat(String format) throws Exception {
this.dateformat = format;
}

/**
* 【获得附件存放路径】
*/
public String getAttachPath() {
return saveAttachPath;
}

/**
* 【真正的保存附件到指定目录里】
*/
private void saveFile(String fileName, InputStream in) throws Exception {
String osName = System.getProperty("os.name");
String storedir = getAttachPath();
String separator = "";
if (osName == null)
osName = "";
if (osName.toLowerCase().indexOf("win") != -1) {
separator = "\\";
if (storedir == null || storedir.equals(""))
storedir = "c:\\tmp";
} else {
separator = "/";
storedir = "/tmp";
}
File storefile = new File(storedir + separator + fileName);
System.out.println("storefile's path: " + storefile.toString());
// for(int i=0;storefile.exists();i++){
// storefile = new File(storedir+separator+fileName+i);
// }
BufferedOutputStream bos = null;
BufferedInputStream bis = null;
try {
bos = new BufferedOutputStream(new FileOutputStream(storefile));
bis = new BufferedInputStream(in);
int c;
while ((c = bis.read()) != -1) {
bos.write(c);
bos.flush();
}
} catch (Exception exception) {
exception.printStackTrace();
throw new Exception("文件保存失败!");
} finally {
bos.close();
bis.close();
}
}

public static void main(String[] args) throws Exception {
Properties props = System.getProperties();
props.put("mail.smtp.host", "smtp.163.com");
props.put("mail.smtp.auth", "true");
Session session = Session.getDefaultInstance(props, null);
URLName urln = new URLName("pop3", "pop3.163.com", 110, null,
"dt_cj2004", "abcdefghij");
Store store = session.getStore(urln);
store.connect();

Folder folder = store.getFolder("spool");
//Folder folder = store.getFullName();

folder.open(Folder.READ_ONLY);
//System.out.println(folder.getNewMessageCount());

Message message[] = folder.getMessages();
System.out.println("Messages's length: " + message.length);
ReciveOneMail pmm = null;
/*

for (int i = 0; i < message.length; i++) {
System.out.println("======================");
pmm = new ReciveOneMail((MimeMessage) message[i]);
System.out
.println("Message " + i + " subject: " + pmm.getSubject());
System.out.println("Message " + i + " sentdate: "
+ pmm.getSentDate());
System.out.println("Message " + i + " replysign: "
+ pmm.getReplySign());
System.out.println("Message " + i + " hasRead: " + pmm.isNew());
System.out.println("Message " + i + " containAttachment: "
+ pmm.isContainAttach((Part) message[i]));
System.out.println("Message " + i + " form: " + pmm.getFrom());
System.out.println("Message " + i + " to: "
+ pmm.getMailAddress("to"));
System.out.println("Message " + i + " cc: "
+ pmm.getMailAddress("cc"));
System.out.println("Message " + i + " bcc: "
+ pmm.getMailAddress("bcc"));
pmm.setDateFormat("yy年MM月dd日 HH:mm");
System.out.println("Message " + i + " sentdate: "
+ pmm.getSentDate());
System.out.println("Message " + i + " Message-ID: "
+ pmm.getMessageId());
// 获得邮件内容===============
pmm.getMailContent((Part) message[i]);
System.out.println("Message " + i + " bodycontent: \r\n"
+ pmm.getBodyText());
pmm.setAttachPath("c:\\");
pmm.saveAttachMent((Part) message[i]);
}
*/
}
}

package com.gwxc.hz.mail.demo;

import java.util.Properties;

import javax.activation.DataHandler;
import javax.activation.FileDataSource;
import javax.mail.BodyPart;
import javax.mail.Message;
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;

public class MyMailTest {

/**
* @param args
*/
public static void main(String[] args) throws Exception {

// 会话===========================
Properties props = System.getProperties();
props.put("mail.smtp.host", "smtp.163.com");
props.put("mail.smtp.auth", "true");// 需要验证
Session session = Session.getDefaultInstance(props, null);

// msg 设置=======================
MimeMessage mimeMsg = new MimeMessage(session);

// 设置标题
mimeMsg.setSubject("标题test");

// 设置内容----begin
Multipart mp = new MimeMultipart();

// 添加文本
BodyPart bp1 = new MimeBodyPart();
bp1.setContent("文本内容", "text/html;charset=GB2312");
mp.addBodyPart(bp1);

// 添加附件
BodyPart bp2 = new MimeBodyPart();
FileDataSource fileds = new FileDataSource("c:\\boot.ini");
bp2.setDataHandler(new DataHandler(fileds));
bp2.setFileName(fileds.getName());
mp.addBodyPart(bp2);

mimeMsg.setContent(mp);
// 设置内容----end

mimeMsg.setFrom(new InternetAddress("[email protected]"));
mimeMsg.setRecipients(Message.RecipientType.TO, InternetAddress
.parse("[email protected]"));
mimeMsg.saveChanges();

// 传输==================================
Transport transport = session.getTransport("smtp");
transport.connect((String) props.get("mail.smtp.host"),
"xiangzhengyan", "pass");
transport.sendMessage(mimeMsg, mimeMsg
.getRecipients(Message.RecipientType.TO));
transport.close();
}

}

Ⅷ javaMail判断收到的邮件是否是回执邮件

我们测试一下,标题是:测试回执

需要回执的原始邮件
Message-ID: <[email protected]>
X-mailer: Foxmail 6, 10, 201, 20 [cn]
Disposition-Notification-To: "php2000" <[email protected]>
Subject: =?gb2312?B?suLK1LvY1rQ=?=

收到的信息
Message-ID: <16446385.5181199249234389.JavaMail.SYSTEM@svctag-hj8w32x>
Subject: =?gb2312?B?suLK1LvY1rQ=?=
MIME-Version: 1.0
X-UserIsAuth: true

回执信息,标题是:已读: 测试回执
References: <16446385.5181199249234389.JavaMail.SYSTEM@svctag-hj8w32x>
Subject: =?gb2312?B?0tG2wTogsuLK1LvY1rQ=?=

从上面看出,你最原始的Message-ID 并没有返回来,所以不能通过这个判断
我唯一能想到的,就是这个啦
Subject: =?gb2312?B?suLK1LvY1rQ=?=

回执会把原始的Subject带回来,所以你应该在Subject里面加上你的唯一编码,不要太长就行。

Ⅸ 关于javamail发送邮件的回执

如果是指检验邮箱是否存在的话,没必要去发送邮件,当然如果发送邮件的话也是可以检验出来的,如果邮箱不存在的话,发送是失败的;更简单一点直接用javaMail中的connect去判定是否存在就可以了:

//根据邮件会话属性和密码验证器构造一个发送邮件的session
SessionsendMailSession=Session
.getDefaultInstance(pro,authenticator);

Transporttransport=sendMailSession.getTransport();

//连接邮件smtp服务器,参数分别为服务器地址,用户名和密码
transport.connect(serverHost,userName,
mpassword);

如果没有报错就返回true,说明邮箱确实存在,否则会抛出MessagingException异常。

Ⅹ javaMail 怎样判断收到的邮件是回执邮件

最准确的方法是看信头 包含Disposition-Notification-To:

最主观是点击那封就提示是否回复

阅读全文

与java邮件回执相关的资料

热点内容
农村老电影800部大全 浏览:851
主角收啦小姨母女的小说 浏览:389
pe系统下硬盘识别不了系统文件 浏览:963
儿媳小说下载 浏览:807
泰国打孩子的鬼片 浏览:837
关于末班车电影有哪些 浏览:275
80年代台湾真军 浏览:15
kies升级固件慢 浏览:424
哪里能看法国啄木鸟系列电 浏览:228
动漫是什么app制作的 浏览:962
upd文件怎么打开 浏览:26
win10初始网络 浏览:517
农村黄片电影名字 浏览:57
word怎么排查文件 浏览:397
武王小说网热门排行榜 浏览:306
p影院免费 浏览:234
bat读取文件指定内容 浏览:514
win10系统带平板模式 浏览:612
催眠系统小说 浏览:294
iphone4升级ios6 浏览:183

友情链接