daily pastebin goal
62%
SHARE
TWEET

Untitled

a guest Jan 20th, 2017 100 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package dashboard;
  2.  
  3. import com.ifountain.opsgenie.client.OpsGenieClientException;
  4. import org.springframework.context.annotation.ComponentScan;
  5.  
  6. import javax.mail.Message;
  7. import javax.mail.MessagingException;
  8. import javax.mail.Session;
  9. import javax.mail.Transport;
  10. import javax.mail.internet.InternetAddress;
  11. import javax.mail.internet.MimeMessage;
  12. import java.io.IOException;
  13. import java.text.ParseException;
  14. import java.util.Properties;
  15.  
  16.  
  17. @ComponentScan()
  18. public class SendDecisionEmail {
  19.  
  20.     public static void decisionFormSubmitterEmail(NewDecision newDecision)
  21.             throws ParseException, OpsGenieClientException, IOException {
  22.  
  23.         String to = "c.logue@improvedigital.com";
  24.         String from = "cm-submission@improvedigital.com";
  25.         String host = "localhost";
  26.  
  27.         Properties properties = System.getProperties();
  28.         properties.setProperty("mail.smtp.host", host);
  29.         Session session = Session.getDefaultInstance(properties);
  30.  
  31.         String message = "<b>Thank you for your submission.</b>";
  32.         message += "Your ID-CR" + newDecision.getRef() + " has been " + newDecision.getApprovalStatus() + ".<br>";
  33.         message += "CLA Comments: " + newDecision.getComments();
  34.  
  35.         try {
  36.             MimeMessage msg = new MimeMessage(session);
  37.             msg.setFrom(new InternetAddress(from));
  38.             msg.addRecipient(Message.RecipientType.TO,
  39.                     new InternetAddress(to));
  40.             msg.setText(message);
  41.             msg.setSubject("Decision on Change Request");
  42.  
  43.             Transport.send(msg);
  44.  
  45.         } catch (MessagingException mex) {
  46.             mex.printStackTrace();
  47.         }
  48.     }
  49.  
  50.  
  51.     public static void decisionFormCLAEmail(NewDecision newDecision, NewRequest newRequest)
  52.             throws ParseException, OpsGenieClientException, IOException {
  53.  
  54.         String to = "c.logue@improvedigital.com";
  55.         String from = "cm-submission@improvedigital.com";
  56.         String host = "localhost";
  57.  
  58.         System.out.println("newRequest = " + newRequest);
  59.  
  60.         Properties properties = System.getProperties();
  61.         properties.setProperty("mail.smtp.host", host);
  62.         Session session = Session.getDefaultInstance(properties);
  63.  
  64.         try {
  65.             MimeMessage msg = new MimeMessage(session);
  66.             msg.setFrom(new InternetAddress(from));
  67.             msg.addRecipient(Message.RecipientType.TO,
  68.                     new InternetAddress(to));
  69.         msg.setText("Thank you for your decision. ID-CR" + newRequest.getRef() + " has been " +
  70.                 newDecision.getApprovalStatus() + ". Submitter Name: " + newRequest.getSubmitterName() +
  71.                 " , Submitter Email: " + newRequest.getSubmitterEmail() +
  72.                 " , Subject Of Change: " + newRequest.getSubjectOfChange() +
  73.                 " , Detailed Change Information: " + newRequest.getDetailedChangeInformation() +
  74.                 " , Why Change Is Required: " + newRequest.getWhyChangeIsRequired() +
  75.                 " , Affected Services: " + newRequest.getAffectedServices() +
  76.                 " , Start Of Change: " + newRequest.getStartOfChange() +
  77.                 " , End Of Change: " + newRequest.getEndOfChange() +
  78.                 " , Release Plan: " + newRequest.getReleasePlan() +
  79.                 " , Rollback Plan: " + newRequest.getRollbackPlan() +
  80.                 " , Additional Comments and Related Ticket: " + newRequest.getAdditionalComments() +
  81.                 " , CLA Comments: " + newDecision.getComments() +
  82.                 " , Approval Status: " + newDecision.getApprovalStatus());
  83.         msg.setSubject("Decision on Change Request");
  84.  
  85.             Transport.send(msg);
  86.  
  87.         } catch (MessagingException mex) {
  88.             mex.printStackTrace();
  89.         }
  90.  
  91.     }
  92.  
  93.     public static void decisionFormLeviEmail(NewDecision newDecision, NewRequest newRequest)
  94.             throws ParseException, OpsGenieClientException, IOException {
  95.  
  96.         String to = "c.logue@improvedigital.com";
  97.         String from = "cm-submission@improvedigital.com";
  98.         String host = "localhost";
  99.  
  100.         Properties properties = System.getProperties();
  101.         properties.setProperty("mail.smtp.host", host);
  102.         Session session = Session.getDefaultInstance(properties);
  103.  
  104.         try {
  105.             MimeMessage msg = new MimeMessage(session);
  106.             msg.setFrom(new InternetAddress(from));
  107.             msg.addRecipient(Message.RecipientType.TO,
  108.                     new InternetAddress(to));
  109.             msg.setText("Change request ID-CR" + newRequest.getRef() + " has been approved by the CLA. " +
  110.                     "Submitter Name: " + newRequest.getSubmitterName() +
  111.                     " , Submitter Email: " + newRequest.getSubmitterEmail() +
  112.                     " , Subject Of Change: " + newRequest.getSubjectOfChange() +
  113.                     " , Detailed Change Information: " + newRequest.getDetailedChangeInformation() +
  114.                     " , Why Change Is Required: " + newRequest.getWhyChangeIsRequired() +
  115.                     " , Affected Services: " + newRequest.getAffectedServices() +
  116.                     " , Start Of Change: " + newRequest.getStartOfChange() +
  117.                     " , End Of Change: " + newRequest.getEndOfChange() +
  118.                     " , Release Plan: " + newRequest.getReleasePlan() +
  119.                     " , Rollback Plan: " + newRequest.getRollbackPlan() +
  120.                     " , Additional Comments and Related Ticket: " + newRequest.getAdditionalComments());
  121.             msg.setSubject("Approval of Change Request");
  122.             Transport.send(msg);
  123.  
  124.         } catch (MessagingException mex) {
  125.             mex.printStackTrace();
  126.         }
  127.  
  128.     }
  129.  
  130.  
  131. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top