|

楼主 |
发表于 2017-12-15 15:57:47
|
显示全部楼层
帮忙看看这样向作流流转时的处理人发送邮件有没有问题:
public void SendMailByActivity(){
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
System.out.println(df.format(new Date())+"发送处理邮件开始...");
String email = null;
String title = null;
String userName = null;
String password = null;
String OpenURL = null;
String task = null;
String eUrl = null;
String process = null;
String activity = null;
String executor = null;
String bsessionid = null;
String personID = null;
String S_url = null;
String UserName_CN = null;
Date date = new Date();
//ArrayList extOrgRelations = new ArrayList();
//extOrgRelations.add("sMail");
Collection<String> cols = new ArrayList();
cols.add("sMail");
for ( ActivityInstance ai : ProcessUtils.getAI().getAllNextAIs()) {
if (ai.getNextAIs().isEmpty()) {
for (Task t : ai.getTask().getExecutorTasks()) {
title = t.getName();
task = t.getId();
eUrl = t.getEURL();
process = t.getProcess();
activity = t.getActivity();
executor = t.getExecutorFID();
//personID = OrgUtils.getIDByFID(t.getExecutorFID(), "psm");
//com.justep.system.opm.api.Person person = PersonHelper.loadPerson(personID, extOrgRelations);
personID = OrgUtils.getPersonIDByFID(t.getExecutorFID());
com.justep.system.opm.api.Person person = PersonHelper.loadPerson(personID,cols);
email = (String) person.getExtValue("sMail");
if( !email.equals(null) && email.length()!=0) {
userName = person.getLoginName();
password = person.getPassword();
UserName_CN = person.getName();
MailSenderInfo mailInfo = new MailSenderInfo();
String ognID = t.getCreatorOgnID();
mailInfo.init(ognID);
S_url = mailInfo.getServerURL();
mailInfo.setValidate(true);
mailInfo.setToAddress(email);//接收者的邮箱地址
mailInfo.setSubject(title);
OpenURL = S_url+"/x5/UI/yqf/email/process/transInfo/login.j?key="
+ getKey()
+ "&task=" + task
+ "&eUrl=" + eUrl
+ "&E=" + userName
+ "&process=" + process
+ "&D=" + password
+ "&activity=" + activity
+ "&executor=" + executor;
String html = "<html>"
+" <head>"
+" <meta http-equiv=\"Content-type\" content=\"text/html; charset=utf-8\" />"
+" </head>"
+" <body>"
+" <style type=\"text/css\">"
+" a:link{text-decoration:none;}a:visited{text-decoration:none;}a:hover{text-decoration:none;}a:active{text-decoration:none;}"
+" </style>"
+" <div>尊敬的"+UserName_CN+"(先生/女士),您好!"
+" <br/> "+title
+" <br/>点击<a style=\"font-weight:bold;\" href="+OpenURL+">【我要处理】</a>可立即处理。"
+" <br/>_________________________________________________________"
+" <br/>来自于【XXXX协同管理系统】"
+" <br/>"+(new SimpleDateFormat("yyyy-MM-dd hh:mm:ss")).format(date)
+" </div>"
+" </body>"
+"</html>";
mailInfo.setContent(html);
SimpleMailSender sms = new SimpleMailSender();
//发送
if (sms.send(mailInfo)){
System.out.println("邮件html发送成功!TO:"+email);
}
else {
System.out.println("邮件html发送失败!TO:"+email);
}
}
else {
System.out.println(df.format(new Date())+"接收人邮件地址为"+String.valueOf(email)+"发送失败!");
}
}
}
}
System.out.println(df.format(new Date())+"发送处理邮件结束。");
}
|
|