package creditfair_websiteapp_email; import java.io.File; import java.util.Map; import creditfair_websiteapp_config.WebsiteappBrowser; import software.amazon.awssdk.auth.credentials.AwsBasicCredentials; import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.ses.SesClient; import software.amazon.awssdk.services.ses.model.*; public class EmailReport extends WebsiteappBrowser { public void emailSend () { WebsiteappBrowser keypasses =new WebsiteappBrowser(); // Replace these with your AWS credentials String accessKey = keypasses.seSkey(); String secretKey = keypasses.sesSecretKey(); // Replace this with the sender's email address String sender = "devteam@creditfair.in"; // Replace this with the recipient's email address String recipient = "pratik@creditfair.in"; // Replace this with the subject of your email String subject = "Website Application Created Successfully"; // Replace this with the body of your email String body = "Application Created Successfully"; File uploadFile = new File(System.getProperty("user.dir")+"/test-output/emailable-report.html"); System.out.println(accessKey + secretKey); StaticCredentialsProvider staticCredentials = StaticCredentialsProvider .create(AwsBasicCredentials.create(accessKey, secretKey)); // Create an SES client SesClient sesClient = SesClient.builder().region(Region.AP_SOUTH_1).credentialsProvider(staticCredentials).build(); // Create a SendEmailRequest SendEmailRequest sendEmailRequest = SendEmailRequest.builder() .source(sender) .destination(Destination.builder().toAddresses(recipient).build()) .message(Message.builder() .subject(Content.builder().data(subject).build()) .body(Body.builder().text(Content.builder().data(body + uploadFile).build()).build()) .build()) .build(); // Send the email SendEmailResponse sendEmailResponse = sesClient.sendEmail(sendEmailRequest); // Print the message ID System.out.println("Email sent. Message ID: " + sendEmailResponse.messageId()); } }