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.





Please add stack trace of the exception you are facing.
– AsSiDe
Aug 28 at 15:33






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.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)