Add Watermarks to Emails

Add Watermarks to Emails in Java

The GroupDocs.Watermark Java API which is part of Conholdate.Total for Java, allows you to get the information about the attachments in an email message. Below is the code snippet for extracting attachments from Email.

EmailLoadOptions loadOptions = new EmailLoadOptions();                                                       
// Constants.InMessageMsg is an absolute or relative path to your document. Ex: "C:\\Docs\\message.msg"      
Watermarker watermarker = new Watermarker(Constants.InMessageMsg, loadOptions);                              
                                                                                                             
EmailContent content = watermarker.getContent(EmailContent.class);                                           
for (EmailAttachment attachment : content.getAttachments())                                                  
{                                                                                                            
    System.out.println("Name: " + attachment.getName());                                                     
    System.out.println("File format: " + attachment.getDocumentInfo().getFileType());                        
                                                                                                             
    FileOutputStream outputStream = new FileOutputStream(Constants.OutputPath + "\\" + attachment.getName());
    outputStream.write(attachment.getContent());                                                             
    outputStream.close();                                                                                    
}                                                                                                            
                                                                                                             
watermarker.close();