How to Save the Email Sent from emailTemplates in .eml file

Hi,
I am sending an Email using jmix’s email templates and i want to save the .eml file of the sent email in my local file storage how can i do that.

I tried using this code but this is only giving me access to INBOX so this is not helpful for me as i want my SENT email to be saved in storage.

tore store = session.getStore("pop3s");
                store.connect(host, username, password);

                // Get inbox folder
                Folder sent = store.getFolder("SENT");
                sent.open(Folder.READ_ONLY);

                Folder[] folders = store.getDefaultFolder().list("*");
                System.out.println("Available folders:");
                for (Folder folder : folders) {
                    System.out.println(folder.getName());
                    // only got INBOX folder here.
                }

                String subjectToSearch = "DEMO 3.0 ||Cancellation Internal";
                SearchTerm searchTerm = new SubjectTerm(subjectToSearch);
                Message[] foundMessages = sent.search(searchTerm);
                
                 if (foundMessages.length > 0) {
                    saveEmailAsEML(foundMessages[0], "/home/Desktop/Template/jmix/"+subjectToSearch+".eml");
                } else {
                    System.out.println("No emails found with the subject: " + subjectToSearch);
                }
                sent.close(false);
                store.close();