提醒邮件demo
2.同意和拒绝使用mailTo标签
<a href="mailto:chao.gao@feixun.com.cn?cc=xu02.xu@feixun.com.cn &subject=OA审批 &body=审批意见:同意<br>审批任务ID:1234567890" target="_blank" style="font-size: 14px; padding: 2px 6px; display: block; color: #ffffff;"> 同意</a>
mailTo标签相比邮件审批的参考系统U8和费控有较大进步:1.不需要用户再输入额外信息;2.回复不再使用邮箱自带的回复功能,可以减少对解析回复邮件的干扰;
3.回复邮件格式
审批意见:同意
审批任务ID:1234567890
备注:同意休假
4.解析过程:
public StringBuffer getMailContent(Part part) throws Exception { StringBuffer bodyText = new StringBuffer(); String contentType = part.getContentType(); // 获得邮件的MimeType类型 // System.out.println("邮件的MimeType类型: " + contentType); int nameIndex = contentType.indexOf("name"); boolean conName = false; if (nameIndex != -1) { conName = true; } // System.out.println("邮件内容的类型: " + contentType); if (part.isMimeType("text/plain") && conName == false) { // text/plain 类型 // bodyText.append((String) part.getContent()); String textContent = (String) part.getContent(); /* String reg1 = ".*审批意见:([^\\r\\n]*)\\r\\n?.*"; String reg2 = ".*审批任务ID:([^\\r\\n|]*)\\r\\n?.*";*/ String reg1 = "[\\s\\S]*审批意见\\s*(:|:)\\s*([^\\r]*)\\|?[\\s\\S]*"; //"[\\s\\S]*审批意见\\s*(:|:)\\s*([\\d\\-]*)\\|?[\\s\\S]*"; String reg2 = "[\\s\\S]*审批任务ID\\s*(:|:)\\s*([\\d\\-]*)\\|?[\\s\\S]*"; String approve = textContent.replaceAll(reg1, "$2"); String taskId = textContent.replaceAll(reg2, "$2"); bodyText.append(approve + "," + taskId); } else if (part.isMimeType("text/html") && conName == false) { // text/html 类型 // bodyText.append((String) part.getContent()); } else if (part.isMimeType("multipart/*")) { // 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")) { // message/rfc822 getMailContent((Part) part.getContent()); } else { } return bodyText; }