Interface MessageTemplate


public interface MessageTemplate
Template for creating mail messages. Use the Admin-interface to get a template instance from the database or create a new one.

Set the message properties like subject, body, recipients using the setter methods. The message is sent with the send method.

  • Method Details

    • setActive

      MessageTemplate setActive(boolean active)
      Set the message template to active. The send method does nothing if the template is inactive. New templates are active by default.
    • setMimeType

      MessageTemplate setMimeType(String mimetype)
      Set the mime-type.
      Parameters:
      mimetype - text/plain or text/html, the latter is the default.
    • setSubject

      MessageTemplate setSubject(String subject)
      Set the message subject. Replacements can be defined.
    • setBody

      MessageTemplate setBody(String body)
      Set the message body. Replacements can be defined.
    • setBodyUrl

      MessageTemplate setBodyUrl(String url)
      Set the message body.
      Parameters:
      url - the url points to a resource in the classpath
    • addRecipients

      MessageTemplate addRecipients(List<Recipient> recs)
      Add a list of recipients.
    • addRecipient

      MessageTemplate addRecipient(Recipient rec)
      Add one recipients.
    • addRecipient

      MessageTemplate addRecipient(User user)
      Add a user as recipient. The email field of the user object is used as recipient.
    • addRecipient

      MessageTemplate addRecipient(String email)
      Add an email address as recipient.
    • clearRecipients

      MessageTemplate clearRecipients(Message.RecipientType type)
      Remove all recipients of the given type from the message.
    • getRecipients

      List<Recipient> getRecipients()
      Return the list of recipients.
    • getReplyTo

      String getReplyTo()
      Get the optional Reply-to header
    • setReplyTo

      MessageTemplate setReplyTo(String replyto)
      Set the Reply-to header
    • getReplyToMsgId

      String getReplyToMsgId()
      Get the optional In-Reply-To header (the message-id of the replying mail)
    • getSenderAddress

      String getSenderAddress()
      Get the sender mail address.
    • addHeader

      MessageTemplate addHeader(String key, String value)
      Add a header field to the message.
    • setReplyToMsgId

      MessageTemplate setReplyToMsgId(String replyto_msgid)
      Set the In-Reply-To header (the message-id of the replying mail)
    • getMessageCharset

      String getMessageCharset()
      Get the character set of the message
    • setMessageCharset

      MessageTemplate setMessageCharset(String charset)
      Set the character set for the message (optionally). If not set, the system default is taken when sending mail.
    • setLogged

      MessageTemplate setLogged(boolean l)
      Log the message into the mail journal.
    • setAddToProcess

      MessageTemplate setAddToProcess(boolean add)
      Add the message to the process.
    • setProcessInstance

      MessageTemplate setProcessInstance(ProcessInstance pi)
      Set the message context (used for template replacements) to the given process instance.
    • setActivityInstance

      MessageTemplate setActivityInstance(ActivityInstance ai)
      Set the message context (used for template replacements) to the given activity instance.
    • setDocument

      MessageTemplate setDocument(DMSObject doc)
      Set the message context (used for template replacements) to the given document.
    • setVariableValue

      MessageTemplate setVariableValue(String key, Object value)
      Define a variable for template substitution. Note, that this method implicitly sets a context.
      Parameters:
      key - a key for referencing the object
      value - the value, can be a string, number, date, persistent, etc.
    • setLocale

      MessageTemplate setLocale(Locale l)
      Set the locale that is used for internationalization of the message.
    • addAttachment

      MessageTemplate addAttachment(BodyPart mbp)
      Add an attachment to the message
    • addInlineBodyPart

      MessageTemplate addInlineBodyPart(BodyPart mbp)
      Add an inline attachment to the mail (optionally). Inline attachments are used by HTML mails only, i.e. the mimetype "text/html" must be set!
    • setQueueAction

      Set the queue behavior. Note, that this method sets the mail sender to the default sender, if none is defined. A later call of setMailSender will overwrite this setting.
      Parameters:
      ma - one of the mail action values: QUEUE, DEFFERRED, NO_QUEUE
    • setMailSender

      MessageTemplate setMailSender(MailSender ms)
      Set the mail sender for using specific properties for sender and communication settings.
    • getMailSender

      MailSender getMailSender()
      get the mail sender
    • getMailQueueItem

      MailQueueItem getMailQueueItem()
      Returns a MailQueueItem which could be set after sending mail
      Returns:
      the MailQueueItem, otherwise null
    • createMessage

      Message createMessage()
      Creates a new Message object with the data of this MessageTemplate.
    • getMessage

      Message getMessage()
      Get the Message object of MessageTemplate instance which has been created by the send() method implicitly or by the createMessage() method explicitly.
    • setReplace

      MessageTemplate setReplace(boolean b)
      Call with true, if you want that replacements are done in subject and body. Default is false for empty MessageTemplates and true for Templates from the database.
      Parameters:
      b -
    • makeReplacements

      void makeReplacements() throws Exception
      Make the replacements in subject and body.
      Throws:
      Exception
    • send

      boolean send()
      Send the message. In this step, the replacements are performed and the Message is generated, if not already done e.g. by method createMessage() or by a previous call of the send() method. Depending on the kind of sending, the message is sent immediately or put into the message queue.
      Returns:
      true, if mail could be sent or false, if mail could not be sent or if mail has been inserted into mail queue. In all other cases an Exception is thrown.
    • getId

      String getId()
      Get the id of the template.
    • getName

      String getName()
      Get the name of the template.
    • getDescription

      String getDescription()
      Get the description of the template.
    • getApplication

      Application getApplication()
      Returns the application of the template.
      Returns:
      the application
    • getSubject

      String getSubject()
      Get the message subject. Note, that after makeReplacements() or createMessage() is called, this method returns the replaced subject.
    • getBody

      String getBody()
      Get the message body. Note, that after makeReplacements() or createMessage() is called, this method returns the replaced body.
    • getMimeType

      String getMimeType()
      Get the mime type
    • isActive

      boolean isActive()
      Is the template active
    • isLogged

      boolean isLogged()
      Returns true if the message is logged in the mail journal
    • isAddedToProcess

      boolean isAddedToProcess()
      Returns true if the mail message is added to the process