5 个解决方案
#1
把网页保存下来,作为附件发。
#2
up
#3
这是客户端的事情,你一般控制不了。
#4
yes
#5
Multipart mp = new MimeMultipart("related");
MimeBodyPart mbodypart1 = new MimeBodyPart();
MimeBodyPart mbodypart = new MimeBodyPart();
MailContentAnalyse mca = new MailContentAnalyse();
mbodypart.setText("请用HTML浏览器查看");
mp.addBodyPart(mbodypart);
sBody = "<html><header></header><body>" + mca.replacePicPath(sBody) +"</body></html>";
mbodypart1.setContent(sBody,"text/html;charset=gb2312");
mp.addBodyPart(mbodypart1);
Vector vecPicPath = mca.GetImagePath();
for(int i=0;i<vecPicPath.size();i++){
MimeBodyPart mbodypart2 = new MimeBodyPart();
String sPath = (String)vecPicPath.get(i);
FileDataSource fds1 = new FileDataSource("D:\\tomcat\\webapps\\"+sPath);
mbodypart2.setFileName(fds1.getName());
mbodypart2.setDataHandler(new DataHandler(fds1));
mbodypart2.setHeader("Content-ID",String.valueOf(i)+"@softvan.com.cn");
mp.addBodyPart(mbodypart2);
}
String sID = Util.convertPostStr(request.getParameter("attachid"));
AttachmentBean attachmentbean = (AttachmentBean) session.getAttribute("jmail_attachmentbean");
if (attachmentbean == null) attachmentbean = new AttachmentBean();
Hashtable h = attachmentbean.getAttachHash(sID);
if (h.size() > 1) {
//have attachment
String s;
for (Enumeration e = h.keys() ; e.hasMoreElements() ;) {
s = (String) e.nextElement();
if (s.equals("TOTALSIZE")) continue;
MimeBodyPart mbp = new MimeBodyPart();
FileDataSource fds = new FileDataSource(userbean.getAttachPath() + "/" + s);
mbp.setDataHandler(new DataHandler(fds));
String encodeFileName = MimeUtility.encodeText(Util.getAttachFileName((String) h.get(s)), "GBK", null);
encodeFileName = Util.replaceStr(encodeFileName, "\r", "");
encodeFileName = Util.replaceStr(encodeFileName, "\n", "");
mbp.setFileName(encodeFileName);
mp.addBodyPart(mbp);
}
}
message.setContent(mp);
#1
把网页保存下来,作为附件发。
#2
up
#3
这是客户端的事情,你一般控制不了。
#4
yes
#5
Multipart mp = new MimeMultipart("related");
MimeBodyPart mbodypart1 = new MimeBodyPart();
MimeBodyPart mbodypart = new MimeBodyPart();
MailContentAnalyse mca = new MailContentAnalyse();
mbodypart.setText("请用HTML浏览器查看");
mp.addBodyPart(mbodypart);
sBody = "<html><header></header><body>" + mca.replacePicPath(sBody) +"</body></html>";
mbodypart1.setContent(sBody,"text/html;charset=gb2312");
mp.addBodyPart(mbodypart1);
Vector vecPicPath = mca.GetImagePath();
for(int i=0;i<vecPicPath.size();i++){
MimeBodyPart mbodypart2 = new MimeBodyPart();
String sPath = (String)vecPicPath.get(i);
FileDataSource fds1 = new FileDataSource("D:\\tomcat\\webapps\\"+sPath);
mbodypart2.setFileName(fds1.getName());
mbodypart2.setDataHandler(new DataHandler(fds1));
mbodypart2.setHeader("Content-ID",String.valueOf(i)+"@softvan.com.cn");
mp.addBodyPart(mbodypart2);
}
String sID = Util.convertPostStr(request.getParameter("attachid"));
AttachmentBean attachmentbean = (AttachmentBean) session.getAttribute("jmail_attachmentbean");
if (attachmentbean == null) attachmentbean = new AttachmentBean();
Hashtable h = attachmentbean.getAttachHash(sID);
if (h.size() > 1) {
//have attachment
String s;
for (Enumeration e = h.keys() ; e.hasMoreElements() ;) {
s = (String) e.nextElement();
if (s.equals("TOTALSIZE")) continue;
MimeBodyPart mbp = new MimeBodyPart();
FileDataSource fds = new FileDataSource(userbean.getAttachPath() + "/" + s);
mbp.setDataHandler(new DataHandler(fds));
String encodeFileName = MimeUtility.encodeText(Util.getAttachFileName((String) h.get(s)), "GBK", null);
encodeFileName = Util.replaceStr(encodeFileName, "\r", "");
encodeFileName = Util.replaceStr(encodeFileName, "\n", "");
mbp.setFileName(encodeFileName);
mp.addBodyPart(mbp);
}
}
message.setContent(mp);