Making Java Mail Body attachment as password protect
Making Java Mail Body attachment as password protect
I have developed a java mail API program which will send the mail and it also attaches the PDF file , so finally a mail is delivered in which PDF file is attached.
i want to make that PDF file as password protected through my java program itself. for an example, when mail receiver receive a mail, receiver click on the PDF file. at that time pop up box need to be appear and user have to type previously generated password to see that PDF file. im developing the function but seems to be struct with the domain. please help me here.
messageBodyPart = new MimeBodyPart();
DataSource source = new FileDataSource("D:/C_App/PDF/"+Employeeid+ ".docx");//add file path
messageBodyPart.setDataHandler(new DataHandler(source));
messageBodyPart.setFileName(Employeeid);//file name to be displayed
multipart.addBodyPart(messageBodyPart);
message.setContent(multipart);
byte USER = "password 1234".getBytes();
byte OWNER = "password 1234".getBytes();
encryptPdf(DataSource source, DataSource source) throws IOException, DocumentException PdfWriter.DO_NOT_ENCRYPT_METADATA);
stamper.close();
reader.close();
Transport.send(message);
This code segment gives me syntax error too. any help would be appreciated.
Thank you.
in the line of encryptedPdf() line segment it is Syntax error on tokens, Type expected instead. and in the stack trace its about Exception in thread "AWT-EventQueue-0" java.lang.Error: Unresolved compilation problems:
– Anushka lakmal
Aug 28 at 15:38
1 Answer
1
encryptPdf(DataSource source, DataSource source) throws IOException, DocumentException PdfWriter.DO_NOT_ENCRYPT_METADATA);
stamper.close();
reader.close();
I also get struct with this part. that why asked help from anyone. truly speaking seems very difficult to implement this for me. help me if you can with the code segemnts
– Anushka lakmal
Aug 28 at 15:49
I found the answer. thanks
– Anushka lakmal
Aug 30 at 5:01
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Please add stack trace of the exception you are facing.
– AsSiDe
Aug 28 at 15:33