Class MailService


  • public final class MailService
    extends java.lang.Object
    Application Mail Service
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String getNoReplyEmail()
      Returns a no reply email address defined in config.properties
      static IMailQueue getQueue()
      Returns the mail queue
      static java.lang.String getSiteLink​(java.lang.String strBaseUrl, boolean linkToFrontOffice)
      Get a string that contains an html link to the site back office or front office.
      static java.lang.String getStrRecipients​(java.util.List<java.lang.String> listRecipients)
      Return a String that contains a list of recipients separated with mail separator
      static java.util.List<UrlAttachment> getUrlAttachmentList​(java.lang.String strHtml, java.lang.String strBaseUrl, boolean useAbsoluteUrl)
      Extract a collection of elements to be attached to a mail from an HTML string.
      static void sendMailCalendar​(java.lang.String strRecipientsTo, java.lang.String strSenderName, java.lang.String strSenderEmail, java.lang.String strSubject, java.lang.String strMessage, java.lang.String strCalendarMessage, boolean bCreateEvent)
      Send a calendar message asynchronously.
      static void sendMailCalendar​(java.lang.String strRecipientsTo, java.lang.String strRecipientsCc, java.lang.String strRecipientsBcc, java.lang.String strSenderName, java.lang.String strSenderEmail, java.lang.String strSubject, java.lang.String strMessage, java.lang.String strCalendarMessage, boolean bCreateEvent)
      Send a calendar message asynchronously.
      static void sendMailCalendar​(java.lang.String strRecipientsTo, java.lang.String strRecipientsCc, java.lang.String strRecipientsBcc, java.lang.String strSenderName, java.lang.String strSenderEmail, java.lang.String strSubject, java.lang.String strMessage, java.lang.String strCalendarMessage, boolean bCreateEvent, boolean bUniqueRecipientTo)
      Send a calendar message asynchronously.
      static void sendMailHtml​(java.lang.String strRecipientsTo, java.lang.String strSenderName, java.lang.String strSenderEmail, java.lang.String strSubject, java.lang.String strMessage)
      Send a HTML message asynchronously.
      static void sendMailHtml​(java.lang.String strRecipientsTo, java.lang.String strRecipientsCc, java.lang.String strRecipientsBcc, java.lang.String strSenderName, java.lang.String strSenderEmail, java.lang.String strSubject, java.lang.String strMessage)
      Send a HTML message asynchronously.
      static void sendMailHtml​(java.lang.String strRecipientsTo, java.lang.String strRecipientsCc, java.lang.String strRecipientsBcc, java.lang.String strSenderName, java.lang.String strSenderEmail, java.lang.String strSubject, java.lang.String strMessage, boolean bUniqueRecipientTo)
      Send a HTML message asynchronously.
      static void sendMailMultipartHtml​(java.lang.String strRecipientsTo, java.lang.String strRecipientsCc, java.lang.String strRecipientsBcc, java.lang.String strSenderName, java.lang.String strSenderEmail, java.lang.String strSubject, java.lang.String strMessage, java.util.List<UrlAttachment> urlsAttachement, java.util.List<FileAttachment> filesAttachement)
      Send a HTML message asynchronously with the attachments associated to the message and attached files .
      static void sendMailMultipartHtml​(java.lang.String strRecipientsTo, java.lang.String strRecipientsCc, java.lang.String strRecipientsBcc, java.lang.String strSenderName, java.lang.String strSenderEmail, java.lang.String strSubject, java.lang.String strMessage, java.util.List<UrlAttachment> urlsAttachement, java.util.List<FileAttachment> filesAttachement, boolean bUniqueRecipientTo)
      Send a HTML message asynchronously with the attachments associated to the message and attached files .
      static void sendMailMultipartHtml​(java.lang.String strRecipientsTo, java.lang.String strSenderName, java.lang.String strSenderEmail, java.lang.String strSubject, java.lang.String strMessage, java.util.List<UrlAttachment> urlsAttachement)
      Send a HTML message asynchronously with the attachments associated to the message .
      static void sendMailMultipartText​(java.lang.String strRecipientsTo, java.lang.String strRecipientsCc, java.lang.String strRecipientsBcc, java.lang.String strSenderName, java.lang.String strSenderEmail, java.lang.String strSubject, java.lang.String strMessage, java.util.List<FileAttachment> filesAttachement)
      Send a text message asynchronously with attached files.
      static void sendMailMultipartText​(java.lang.String strRecipientsTo, java.lang.String strRecipientsCc, java.lang.String strRecipientsBcc, java.lang.String strSenderName, java.lang.String strSenderEmail, java.lang.String strSubject, java.lang.String strMessage, java.util.List<FileAttachment> filesAttachement, boolean bUniqueRecipientTo)
      Send a text message asynchronously with attached files.
      static void sendMailMultipartText​(java.lang.String strRecipientsTo, java.lang.String strSenderName, java.lang.String strSenderEmail, java.lang.String strSubject, java.lang.String strMessage, java.util.List<FileAttachment> filesAttachement)
      Send a text message asynchronously with attached files.
      static void sendMailText​(java.lang.String strRecipientsTo, java.lang.String strSenderName, java.lang.String strSenderEmail, java.lang.String strSubject, java.lang.String strMessage)
      Send a text message asynchronously.
      static void sendMailText​(java.lang.String strRecipientsTo, java.lang.String strRecipientsCc, java.lang.String strRecipientsBcc, java.lang.String strSenderName, java.lang.String strSenderEmail, java.lang.String strSubject, java.lang.String strMessage)
      Send a text message asynchronously.
      static void sendMailText​(java.lang.String strRecipientsTo, java.lang.String strRecipientsCc, java.lang.String strRecipientsBcc, java.lang.String strSenderName, java.lang.String strSenderEmail, java.lang.String strSubject, java.lang.String strMessage, boolean bUniqueRecipientTo)
      Send a text message asynchronously.
      static void shutdown()
      Shutdown the service
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • sendMailHtml

        public static void sendMailHtml​(java.lang.String strRecipientsTo,
                                        java.lang.String strSenderName,
                                        java.lang.String strSenderEmail,
                                        java.lang.String strSubject,
                                        java.lang.String strMessage)
        Send a HTML message asynchronously. The message is queued until a daemon thread send all awaiting messages
        Parameters:
        strRecipientsTo - The list of the main recipients email.Every recipient must be separated by the mail separator define in config.properties
        strSenderName - The sender name.
        strSenderEmail - The sender email address.
        strSubject - The message subject.
        strMessage - The message.
      • sendMailHtml

        public static void sendMailHtml​(java.lang.String strRecipientsTo,
                                        java.lang.String strRecipientsCc,
                                        java.lang.String strRecipientsBcc,
                                        java.lang.String strSenderName,
                                        java.lang.String strSenderEmail,
                                        java.lang.String strSubject,
                                        java.lang.String strMessage)
        Send a HTML message asynchronously. The message is queued until a daemon thread send all awaiting messages
        Parameters:
        strRecipientsTo - The list of the main recipients email.Every recipient must be separated by the mail separator defined in config.properties
        strRecipientsCc - The recipients list of the carbon copies .
        strRecipientsBcc - The recipients list of the blind carbon copies .
        strSenderName - The sender name.
        strSenderEmail - The sender email address.
        strSubject - The message subject.
        strMessage - The message.
      • sendMailHtml

        public static void sendMailHtml​(java.lang.String strRecipientsTo,
                                        java.lang.String strRecipientsCc,
                                        java.lang.String strRecipientsBcc,
                                        java.lang.String strSenderName,
                                        java.lang.String strSenderEmail,
                                        java.lang.String strSubject,
                                        java.lang.String strMessage,
                                        boolean bUniqueRecipientTo)
        Send a HTML message asynchronously. The message is queued until a daemon thread send all awaiting messages
        Parameters:
        strRecipientsTo - The list of the main recipients email.Every recipient must be separated by the mail separator defined in config.properties
        strRecipientsCc - The recipients list of the carbon copies .
        strRecipientsBcc - The recipients list of the blind carbon copies .
        strSenderName - The sender name.
        strSenderEmail - The sender email address.
        strSubject - The message subject.
        strMessage - The message.
        bUniqueRecipientTo - true if the mail must be send unitarily for each recipient
      • sendMailMultipartHtml

        public static void sendMailMultipartHtml​(java.lang.String strRecipientsTo,
                                                 java.lang.String strSenderName,
                                                 java.lang.String strSenderEmail,
                                                 java.lang.String strSubject,
                                                 java.lang.String strMessage,
                                                 java.util.List<UrlAttachment> urlsAttachement)
        Send a HTML message asynchronously with the attachments associated to the message . The message is queued until a daemon thread send all awaiting messages
        Parameters:
        strRecipientsTo - The list of the main recipients email.Every recipient must be separated by the mail separator defined in config.properties
        strSenderName - The sender name.
        strSenderEmail - The sender email address.
        strSubject - The message subject.
        strMessage - The message.
        urlsAttachement - The List of UrlAttachement Object, containing the URL of attachments associated with their content-location.
      • sendMailMultipartHtml

        public static void sendMailMultipartHtml​(java.lang.String strRecipientsTo,
                                                 java.lang.String strRecipientsCc,
                                                 java.lang.String strRecipientsBcc,
                                                 java.lang.String strSenderName,
                                                 java.lang.String strSenderEmail,
                                                 java.lang.String strSubject,
                                                 java.lang.String strMessage,
                                                 java.util.List<UrlAttachment> urlsAttachement,
                                                 java.util.List<FileAttachment> filesAttachement)
        Send a HTML message asynchronously with the attachments associated to the message and attached files . The message is queued until a daemon thread send all awaiting messages
        Parameters:
        strRecipientsTo - The list of the main recipients email.Every recipient must be separated by the mail separator defined in config.properties
        strRecipientsCc - The recipients list of the carbon copies .
        strRecipientsBcc - The recipients list of the blind carbon copies .
        strSenderName - The sender name.
        strSenderEmail - The sender email address.
        strSubject - The message subject.
        strMessage - The message.
        urlsAttachement - The List of UrlAttachement Object, containing the URL of attachments associated with their content-location
        filesAttachement - The list of attached files.
      • sendMailMultipartHtml

        public static void sendMailMultipartHtml​(java.lang.String strRecipientsTo,
                                                 java.lang.String strRecipientsCc,
                                                 java.lang.String strRecipientsBcc,
                                                 java.lang.String strSenderName,
                                                 java.lang.String strSenderEmail,
                                                 java.lang.String strSubject,
                                                 java.lang.String strMessage,
                                                 java.util.List<UrlAttachment> urlsAttachement,
                                                 java.util.List<FileAttachment> filesAttachement,
                                                 boolean bUniqueRecipientTo)
        Send a HTML message asynchronously with the attachments associated to the message and attached files . The message is queued until a daemon thread send all awaiting messages
        Parameters:
        strRecipientsTo - The list of the main recipients email.Every recipient must be separated by the mail separator defined in config.properties
        strRecipientsCc - The recipients list of the carbon copies .
        strRecipientsBcc - The recipients list of the blind carbon copies .
        strSenderName - The sender name.
        strSenderEmail - The sender email address.
        strSubject - The message subject.
        strMessage - The message.
        urlsAttachement - The List of UrlAttachement Object, containing the URL of attachments associated with their content-location
        filesAttachement - The list of attached files.
        bUniqueRecipientTo - true if the mail must be send unitarily for each recipient
      • sendMailCalendar

        public static void sendMailCalendar​(java.lang.String strRecipientsTo,
                                            java.lang.String strSenderName,
                                            java.lang.String strSenderEmail,
                                            java.lang.String strSubject,
                                            java.lang.String strMessage,
                                            java.lang.String strCalendarMessage,
                                            boolean bCreateEvent)
        Send a calendar message asynchronously. The message is queued until a daemon thread send all awaiting messages
        Parameters:
        strRecipientsTo - The list of the main recipients email. Every recipient must be separated by the mail separator defined in config.properties
        strSenderName - The sender name.
        strSenderEmail - The sender email address.
        strSubject - The message subject.
        strMessage - The message.
        strCalendarMessage - The calendar message
        bCreateEvent - True to create the calendar event, false to remove it
      • sendMailCalendar

        public static void sendMailCalendar​(java.lang.String strRecipientsTo,
                                            java.lang.String strRecipientsCc,
                                            java.lang.String strRecipientsBcc,
                                            java.lang.String strSenderName,
                                            java.lang.String strSenderEmail,
                                            java.lang.String strSubject,
                                            java.lang.String strMessage,
                                            java.lang.String strCalendarMessage,
                                            boolean bCreateEvent)
        Send a calendar message asynchronously. The message is queued until a daemon thread send all awaiting messages
        Parameters:
        strRecipientsTo - The list of the main recipients email. Every recipient must be separated by the mail separator defined in config.properties
        strRecipientsCc - The recipients list of the carbon copies .
        strRecipientsBcc - The recipients list of the blind carbon copies .
        strSenderName - The sender name.
        strSenderEmail - The sender email address.
        strSubject - The message subject.
        strMessage - The message.
        strCalendarMessage - The calendar message
        bCreateEvent - True to create the calendar event, false to remove it
      • sendMailCalendar

        public static void sendMailCalendar​(java.lang.String strRecipientsTo,
                                            java.lang.String strRecipientsCc,
                                            java.lang.String strRecipientsBcc,
                                            java.lang.String strSenderName,
                                            java.lang.String strSenderEmail,
                                            java.lang.String strSubject,
                                            java.lang.String strMessage,
                                            java.lang.String strCalendarMessage,
                                            boolean bCreateEvent,
                                            boolean bUniqueRecipientTo)
        Send a calendar message asynchronously. The message is queued until a daemon thread send all awaiting messages
        Parameters:
        strRecipientsTo - The list of the main recipients email. Every recipient must be separated by the mail separator defined in config.properties
        strRecipientsCc - The recipients list of the carbon copies .
        strRecipientsBcc - The recipients list of the blind carbon copies .
        strSenderName - The sender name.
        strSenderEmail - The sender email address.
        strSubject - The message subject.
        strMessage - The message.
        strCalendarMessage - The calendar message
        bCreateEvent - True to create the calendar event, false to remove it
        bUniqueRecipientTo - true if the mail must be send unitarily for each recipient
      • sendMailText

        public static void sendMailText​(java.lang.String strRecipientsTo,
                                        java.lang.String strSenderName,
                                        java.lang.String strSenderEmail,
                                        java.lang.String strSubject,
                                        java.lang.String strMessage)
        Send a text message asynchronously. The message is queued until a daemon thread send all awaiting messages
        Parameters:
        strRecipientsTo - The list of the main recipients email. Every recipient must be separated by the mail separator defined in config.properties
        strSenderName - The sender name.
        strSenderEmail - The sender email address.
        strSubject - The message subject.
        strMessage - The message.
      • sendMailText

        public static void sendMailText​(java.lang.String strRecipientsTo,
                                        java.lang.String strRecipientsCc,
                                        java.lang.String strRecipientsBcc,
                                        java.lang.String strSenderName,
                                        java.lang.String strSenderEmail,
                                        java.lang.String strSubject,
                                        java.lang.String strMessage)
        Send a text message asynchronously. The message is queued until a daemon thread send all awaiting messages
        Parameters:
        strRecipientsTo - The list of the main recipients email. Every recipient must be separated by the mail separator defined in config.properties
        strRecipientsCc - The recipients list of the carbon copies .
        strRecipientsBcc - The recipients list of the blind carbon copies .
        strSenderName - The sender name.
        strSenderEmail - The sender email address.
        strSubject - The message subject.
        strMessage - The message.
      • sendMailText

        public static void sendMailText​(java.lang.String strRecipientsTo,
                                        java.lang.String strRecipientsCc,
                                        java.lang.String strRecipientsBcc,
                                        java.lang.String strSenderName,
                                        java.lang.String strSenderEmail,
                                        java.lang.String strSubject,
                                        java.lang.String strMessage,
                                        boolean bUniqueRecipientTo)
        Send a text message asynchronously. The message is queued until a daemon thread send all awaiting messages
        Parameters:
        strRecipientsTo - The list of the main recipients email. Every recipient must be separated by the mail separator defined in config.properties
        strRecipientsCc - The recipients list of the carbon copies .
        strRecipientsBcc - The recipients list of the blind carbon copies .
        strSenderName - The sender name.
        strSenderEmail - The sender email address.
        strSubject - The message subject.
        strMessage - The message.
        bUniqueRecipientTo - true if the mail must be send unitarily for each recipient
      • sendMailMultipartText

        public static void sendMailMultipartText​(java.lang.String strRecipientsTo,
                                                 java.lang.String strSenderName,
                                                 java.lang.String strSenderEmail,
                                                 java.lang.String strSubject,
                                                 java.lang.String strMessage,
                                                 java.util.List<FileAttachment> filesAttachement)
        Send a text message asynchronously with attached files. The message is queued until a daemon thread send all awaiting messages
        Parameters:
        strRecipientsTo - The list of the main recipients email.Every recipient must be separated by the mail separator defined in config.properties
        strSenderName - The sender name.
        strSenderEmail - The sender email address.
        strSubject - The message subject.
        strMessage - The message.
        filesAttachement - The list of attached files.
      • sendMailMultipartText

        public static void sendMailMultipartText​(java.lang.String strRecipientsTo,
                                                 java.lang.String strRecipientsCc,
                                                 java.lang.String strRecipientsBcc,
                                                 java.lang.String strSenderName,
                                                 java.lang.String strSenderEmail,
                                                 java.lang.String strSubject,
                                                 java.lang.String strMessage,
                                                 java.util.List<FileAttachment> filesAttachement)
        Send a text message asynchronously with attached files. The message is queued until a daemon thread send all awaiting messages
        Parameters:
        strRecipientsTo - The list of the main recipients email.Every recipient must be separated by the mail separator defined in config.properties
        strRecipientsCc - The recipients list of the carbon copies .
        strRecipientsBcc - The recipients list of the blind carbon copies .
        strSenderName - The sender name.
        strSenderEmail - The sender email address.
        strSubject - The message subject.
        strMessage - The message.
        filesAttachement - The list of attached files.
      • sendMailMultipartText

        public static void sendMailMultipartText​(java.lang.String strRecipientsTo,
                                                 java.lang.String strRecipientsCc,
                                                 java.lang.String strRecipientsBcc,
                                                 java.lang.String strSenderName,
                                                 java.lang.String strSenderEmail,
                                                 java.lang.String strSubject,
                                                 java.lang.String strMessage,
                                                 java.util.List<FileAttachment> filesAttachement,
                                                 boolean bUniqueRecipientTo)
        Send a text message asynchronously with attached files. The message is queued until a daemon thread send all awaiting messages
        Parameters:
        strRecipientsTo - The list of the main recipients email.Every recipient must be separated by the mail separator defined in config.properties
        strRecipientsCc - The recipients list of the carbon copies .
        strRecipientsBcc - The recipients list of the blind carbon copies .
        strSenderName - The sender name.
        strSenderEmail - The sender email address.
        strSubject - The message subject.
        strMessage - The message.
        filesAttachement - The list of attached files.
        bUniqueRecipientTo - true if the mail must be send unitarily for each recipient
      • shutdown

        public static void shutdown()
        Shutdown the service
      • getNoReplyEmail

        public static java.lang.String getNoReplyEmail()
        Returns a no reply email address defined in config.properties
        Returns:
        A no reply email
      • getQueue

        public static IMailQueue getQueue()
        Returns the mail queue
        Returns:
        the mail queue
      • getUrlAttachmentList

        public static java.util.List<UrlAttachment> getUrlAttachmentList​(java.lang.String strHtml,
                                                                         java.lang.String strBaseUrl,
                                                                         boolean useAbsoluteUrl)
        Extract a collection of elements to be attached to a mail from an HTML string. The collection contains the Url used for created DataHandler for each url associated with an HTML tag img, script or link. Those urls must start with the url strBaseUrl.
        Parameters:
        strHtml - The HTML code.
        strBaseUrl - The base url, can be null in order to extract all urls.
        useAbsoluteUrl - Determine if we use absolute or relative url for attachement content-location
        Returns:
        a collection of UrlAttachment Object for created DataHandler associated with attachment urls.
      • getStrRecipients

        public static java.lang.String getStrRecipients​(java.util.List<java.lang.String> listRecipients)
        Return a String that contains a list of recipients separated with mail separator
        Parameters:
        listRecipients - a list of string recipients
        Returns:
        a String that contains a list of recipients separated with mail separator
      • getSiteLink

        public static java.lang.String getSiteLink​(java.lang.String strBaseUrl,
                                                   boolean linkToFrontOffice)
        Get a string that contains an html link to the site back office or front office.
        Parameters:
        strBaseUrl - The base url of the site
        linkToFrontOffice - True if the link should be directed to the front office, false if it should be directed to the back office.
        Returns:
        A string containing an html link.