Skip to content
Snippets Groups Projects
Commit 8044d241 authored by Abdi Suufi's avatar Abdi Suufi :smile:
Browse files

Extra Service task

Lets EndUser that submits ticket using email submissions that they need to log in with webportal when they're requested to provide more information
parent 1994804d
No related branches found
No related tags found
No related merge requests found
No preview for this file type
package com.example.workflow;
import jakarta.inject.Named;
import javax.inject.Inject;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;
import javax.mail.*;
import javax.mail.internet.*;
import java.util.Properties;
@Named
public class RequestMoreInfoNotificationService implements JavaDelegate {
@Override
public void execute(DelegateExecution execution) throws Exception {
// 1. Retrieve username (assuming it holds the recipient email)
String recipientEmail = (String) execution.getVariable("EmailAddress");
// 2. Construct notification message
String updateMessage = "We require additional information to proceed with your ticket. Please provide the necessary details from the webportal using login details user:demo password: demo and your email address";
// 3. Send notification email
sendNotificationEmail(recipientEmail, updateMessage, "Additional Information Required!");
}
private void sendNotificationEmail(String recipientEmail, String messageBody, String subject) {
// Email configuration
String host = "smtp.gmail.com";
String username = "user.ticketing.systemg2@gmail.com";
String password = "xpzjeayahydrjiib";
Properties props = new Properties();
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.host", host);
props.put("mail.smtp.port", "587");
// Create session with authentication
Session session = Session.getInstance(props, new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
try {
// Create MimeMessage object
Message message = new MimeMessage(session);
// Set From: header field
message.setFrom(new InternetAddress(username));
// Set To: header field
message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(recipientEmail));
// Set Subject: header field
message.setSubject(subject);
// Set message body
message.setText(messageBody);
// Send email
Transport.send(message);
System.out.println("Email sent successfully to " + recipientEmail);
} catch (MessagingException e) {
throw new RuntimeException(e);
}
}
}
\ No newline at end of file
This diff is collapsed.
File added
File added
File added
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment