import com.dassault_systemes.enovia.changerequest.impl.AffectedItem; import com.dassault_systemes.enovia.enterprisechangemgt.common.ChangeAction; import matrix.db.Context; import javax.mail.*; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; import java.util.HashMap; import java.util.Map; import java.util.Properties; import java.util.logging.Logger; public class AegChange3_mxJPO { private static final Logger LOGGER = Logger.getLogger(AegChange3_mxJPO.class.getName()); private static final String SEND_EMAIL = "aeg-scan@csge.com"; private static final String SEND_PASSWORD = "abcd-1234"; private static final String SMTP_HOST = "smtp.qiye.aliyun.com"; private static final String SMTP_PORT = "25"; private static final String EMAIL = "1654607107@qq.com"; public void AegChangeNotify(Context context, String[] args) throws Exception { String caId = args[0]; LOGGER.info("caId == > " + caId); // String getChangeType = "print bus " + caId + " select type dump |"; // String changeType = MqlUtil.mqlCommand(context, getChangeType); // // if("Change Action".equals(changeType)){ // // String getCAInfo = "print bus " + caId + " select name attribute[Synopsis] description attribute[XP_ChangeAction_Ext.DistributionPersonList] attribute[Originator] dump |"; // String caInfo = MqlUtil.mqlCommand(context, getCAInfo); // // String[] caInfoItem = caInfo.split("\\|"); // // } ChangeAction changeAction = new ChangeAction(""); changeAction.getAffectedItems(context); Map map = new HashMap<>(); map.put("projectName", "123"); map.put("taskName", "123"); map.put("description", "123"); map.put("DocumentRecipient", "123"); map.put("taskOwner", "123"); send(map); } public void send(Map itemMap){ LOGGER.info("=============> + <================="); Properties properties = new Properties(); properties.put("mail.smtp.auth", "true"); properties.put("mail.smtp.starttls.enable", "true"); properties.put("mail.smtp.host", SMTP_HOST); properties.put("mail.smtp.port", SMTP_PORT); properties.put("mail.smtp.ssl.protocols", "TLSv1.2"); Session session = Session.getInstance(properties, new javax.mail.Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(SEND_EMAIL, SEND_PASSWORD); } }); session.setDebug(true); Message message = new MimeMessage(session); try { message.setFrom(new InternetAddress(SEND_EMAIL)); message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(EMAIL)); String body = "
" + "
\n" + "

" + itemMap.get("projectName") + "

\n" + "
" + "
\n" + "
\n" + "

" + "\u4efb\u52a1\u540d\u79f0: " + itemMap.get("taskName") + "

\n" + "

" + "\u4efb\u52a1\u63cf\u8ff0: " + itemMap.get("description") + "

\n" + "

" + "\u4efb\u52a1\u6240\u6709\u8005: " + itemMap.get("taskOwner") + "

\n" + "

" + "\u6587\u4ef6\u63a5\u6536\u4eba: " + itemMap.get("DocumentRecipient") + "

\n" + " 查看任务\n" + "
\n" + "
\n" + "
\n" + "

\u672c\u90ae\u4ef6\u53ca\u6240\u6709\u9644\u4ef6\u4ec5\u4f9b\u6536\u4ef6\u5730\u5740\u4e2d\u7684\u4e2a\u4eba\u6216\u5b9e\u4f53\u4f7f\u7528\uff0c\u8fd9\u4e9b\u5185\u5bb9\u5747\u5c5e\u673a\u5bc6\u4fe1\u606f\u5e76\u6216\u8bbe\u6709\u6743\u9650

\n" + "
\n" + "
\n" + "

\u5982\u679c\u60a8\u4e0d\u662f\u4efb\u4f55\u6307\u5b9a\u7684\u6536\u4ef6\u4eba\u6216\u8bef\u6536\u5230\u672c\u90ae\u4ef6,
\n" + " (i) \u60a8\u4e0d\u80fd\u9605\u8bfb\u3001\u6cc4\u6f0f\u6216\u590d\u5236\u672c\u90ae\u4ef6;
\n" + " (ii) \u8bf7\u901a\u8fc7\u7535\u5b50\u90ae\u4ef6\u901a\u77e5\u60a8\u6536\u4ef6\u7684\u53d1\u4ef6\u4eba\u5e76\u5220\u9664\u672c\u90ae\u4ef6\u53ca\u6240\u6709\u9644\u4ef6;
\n" + " (iii) \u5bf9\u4e8e\u56e0\u4f7f\u7528\u6216\u4f9d\u636e\u672c\u90ae\u4ef6\u800c\u5f15\u8d77\u7684\u4efb\u4f55\u635f\u5931\u6216\u635f\u5bb3,Dassault Systemes \u6982\u4e0d\u8d1f\u8d23\u6216\u627f\u62c5\u8d23\u4efb。

\n" + "
\n" + "
"; message.setSubject("subject"); message.setContent(body, "text/html;charset=utf-8"); Transport.send(message); } catch (MessagingException e) { throw new RuntimeException(); } } }