-
提醒邮件demo
2.同意和拒绝使用mailTo标签
|
1
2
3
4
5
6
7
|
&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.解析过程:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
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;
}
|
本文转自 gaochaojs 51CTO博客,原文链接:http://blog.51cto.com/jncumter/1792076,如需转载请自行联系原作者