Package com.logicaldoc.core.automation
Class MailTool
java.lang.Object
com.logicaldoc.core.automation.MailTool
Utility functions to handle emails and send messages from within the
 Automation
- Since:
- 7.5.1
- Author:
- Marco Meschieri - LogicalDOC
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptiondocumentToEMail(Document document, boolean extractAttachments) Creates anEMailobject given the document that stores an email message.extractAttachments(Document doc, String filterFileName, String username) Extracts attachments of email files (.eml, .msg) in the current foldervoidSends a document by email to a recipientvoidsendDocument(Document document, String from, Collection<String> to, String subject, String message) Sends a document by email to a selection of recipientsvoidsendDocuments(Collection<Document> documents, String from, String to, String subject, String message) Sends some documents to a recipientvoidsendDocuments(Collection<Document> documents, String from, Collection<String> to, String subject, String message) Sends some documents to a selection of recipientsvoidsendMessage(long tenantId, String from, String to, String subject, String message) Sends a simple email to a recipientvoidsendMessage(long tenantId, String from, Collection<String> to, String subject, String message) Sends a simple email to a selection of recipientsvoidsendSystemMessage(String recipient, String message, String subject, int scope, int priority) Sends a system message to a user
- 
Constructor Details- 
MailToolpublic MailTool()
 
- 
- 
Method Details- 
sendDocumentspublic void sendDocuments(Collection<Document> documents, String from, String to, String subject, String message) throws IOException, jakarta.mail.MessagingException Sends some documents to a recipient- Parameters:
- documents- collection of documents to send
- from- the email address to be used as From
- to- the email address of the recipient
- subject- subject of the email
- message- message printed in the body of the email
- Throws:
- jakarta.mail.MessagingException- Cannot send the email
- IOException- I/O error
 
- 
sendDocumentspublic void sendDocuments(Collection<Document> documents, String from, Collection<String> to, String subject, String message) throws IOException, jakarta.mail.MessagingException Sends some documents to a selection of recipients- Parameters:
- documents- collection of documents to send
- from- the email address to be used as From
- to- collection of email addresses to send the email to
- subject- subject of the email
- message- message printed in the body of the email
- Throws:
- IOException- I/O error
- jakarta.mail.MessagingException
 
- 
sendDocumentpublic void sendDocument(Document document, String from, String to, String subject, String message) throws IOException, jakarta.mail.MessagingException Sends a document by email to a recipient- Parameters:
- document- the document to send
- from- the email address to be used as From
- to- email addresses of the recipient
- subject- subject of the email
- message- message printed in the body of the email
- Throws:
- IOException- I/O error
- jakarta.mail.MessagingException- Cannot send the email
 
- 
sendDocumentpublic void sendDocument(Document document, String from, Collection<String> to, String subject, String message) throws IOException, jakarta.mail.MessagingException Sends a document by email to a selection of recipients- Parameters:
- document- the document to send
- from- the email address to be used as From
- to- collection of email addresses to send the email to
- subject- subject of the email
- message- message printed in the body of the email
- Throws:
- IOException- I/O error
- jakarta.mail.MessagingException- Cannot send the email
 
- 
sendMessagepublic void sendMessage(long tenantId, String from, Collection<String> to, String subject, String message) throws jakarta.mail.MessagingException Sends a simple email to a selection of recipients- Parameters:
- tenantId- identifier of the tenant
- from- the email address to be used as From
- to- collection of email addresses to send the email to
- subject- subject of the email
- message- message printed in the body of the email
- Throws:
- jakarta.mail.MessagingException- Cannot send the message
 
- 
sendMessagepublic void sendMessage(long tenantId, String from, String to, String subject, String message) throws jakarta.mail.MessagingException Sends a simple email to a recipient- Parameters:
- tenantId- identifier of the tenant
- from- the email address to be used as From
- to- email address of the recipient
- subject- subject of the email
- message- message printed in the body of the email
- Throws:
- jakarta.mail.MessagingException- Cannot send the email
 
- 
documentToEMailpublic EMail documentToEMail(Document document, boolean extractAttachments) throws jakarta.mail.MessagingException, IOException Creates anEMailobject given the document that stores an email message.- Parameters:
- document- the document that contains the email(must be a .eml or a .msg)
- extractAttachments- if the attachments binaries have to be extracted
- Returns:
- The object representation of the email
- Throws:
- IOException- I/O error getting the document's contents
- jakarta.mail.MessagingException- Cannot read the source message
 
- 
sendSystemMessagepublic void sendSystemMessage(String recipient, String message, String subject, int scope, int priority) throws PersistenceException Sends a system message to a user- Parameters:
- recipient- username of the recipient
- message- body of the message
- subject- subject of the message
- scope- number of days the message will stay active before expiring
- priority- a priority: 0 = low, 1 = medium, 2 = high
- Throws:
- PersistenceException- Error in the persistence layer
 
- 
extractAttachmentsExtracts attachments of email files (.eml, .msg) in the current folder- Parameters:
- doc- the document
- filterFileName- a filter on the extensions of the attachment to be extracted (comma separated)
- username- the user that will be impersonated to write the attachments
- Returns:
- a list with the new documents created
 
 
-