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 Summary
-
Method Summary
Modifier and TypeMethodDescriptiondocumentToEMail
(Document document, boolean extractAttachments) Creates anEMail
object 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 foldervoid
Sends a document by email to a recipientvoid
sendDocument
(Document document, String from, Collection<String> to, String subject, String message) Sends a document by email to a selection of recipientsvoid
sendDocuments
(Collection<Document> documents, String from, String to, String subject, String message) Sends some documents to a recipientvoid
sendDocuments
(Collection<Document> documents, String from, Collection<String> to, String subject, String message) Sends some documents to a selection of recipientsvoid
sendMessage
(long tenantId, String from, String to, String subject, String message) Sends a simple email to a recipientvoid
sendMessage
(long tenantId, String from, Collection<String> to, String subject, String message) Sends a simple email to a selection of recipientsvoid
sendSystemMessage
(String recipient, String message, String subject, int scope, int priority) Sends a system message to a user
-
Constructor Details
-
MailTool
public MailTool()
-
-
Method Details
-
sendDocuments
public void sendDocuments(Collection<Document> documents, String from, String to, String subject, String message) throws IOException, javax.mail.MessagingException Sends some documents to a recipient- Parameters:
documents
- collection of documents to sendfrom
- the email address to be used as Fromto
- the email address of the recipientsubject
- subject of the emailmessage
- message printed in the body of the email- Throws:
javax.mail.MessagingException
- Cannot send the emailIOException
- I/O error
-
sendDocuments
public void sendDocuments(Collection<Document> documents, String from, Collection<String> to, String subject, String message) throws IOException, javax.mail.MessagingException Sends some documents to a selection of recipients- Parameters:
documents
- collection of documents to sendfrom
- the email address to be used as Fromto
- collection of email addresses to send the email tosubject
- subject of the emailmessage
- message printed in the body of the email- Throws:
IOException
- I/O errorjavax.mail.MessagingException
-
sendDocument
public void sendDocument(Document document, String from, String to, String subject, String message) throws IOException, javax.mail.MessagingException Sends a document by email to a recipient- Parameters:
document
- the document to sendfrom
- the email address to be used as Fromto
- email addresses of the recipientsubject
- subject of the emailmessage
- message printed in the body of the email- Throws:
IOException
- I/O errorjavax.mail.MessagingException
- Cannot send the email
-
sendDocument
public void sendDocument(Document document, String from, Collection<String> to, String subject, String message) throws IOException, javax.mail.MessagingException Sends a document by email to a selection of recipients- Parameters:
document
- the document to sendfrom
- the email address to be used as Fromto
- collection of email addresses to send the email tosubject
- subject of the emailmessage
- message printed in the body of the email- Throws:
IOException
- I/O errorjavax.mail.MessagingException
- Cannot send the email
-
sendMessage
public void sendMessage(long tenantId, String from, Collection<String> to, String subject, String message) throws javax.mail.MessagingException Sends a simple email to a selection of recipients- Parameters:
tenantId
- identifier of the tenantfrom
- the email address to be used as Fromto
- collection of email addresses to send the email tosubject
- subject of the emailmessage
- message printed in the body of the email- Throws:
javax.mail.MessagingException
- Cannot send the message
-
sendMessage
public void sendMessage(long tenantId, String from, String to, String subject, String message) throws javax.mail.MessagingException Sends a simple email to a recipient- Parameters:
tenantId
- identifier of the tenantfrom
- the email address to be used as Fromto
- email address of the recipientsubject
- subject of the emailmessage
- message printed in the body of the email- Throws:
javax.mail.MessagingException
- Cannot send the email
-
documentToEMail
public EMail documentToEMail(Document document, boolean extractAttachments) throws javax.mail.MessagingException, IOException Creates anEMail
object 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 contentsjavax.mail.MessagingException
- Cannot read the source message
-
sendSystemMessage
public 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 recipientmessage
- body of the messagesubject
- subject of the messagescope
- number of days the message will stay active before expiringpriority
- a priority: 0 = low, 1 = medium, 2 = high- Throws:
PersistenceException
- Error in the persistence layer
-
extractAttachments
Extracts attachments of email files (.eml, .msg) in the current folder- Parameters:
doc
- the documentfilterFileName
- 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
-