Class MailBuilder

java.lang.Object
de.uplanet.lucy.server.mail.MailBuilder

public final class MailBuilder extends Object
The MailBuilder class creates MIME messages with different content-types, manages attachments, and inline pictures using HTML mail.
  • Constructor Details

    • MailBuilder

      public MailBuilder(Path p_dirTmp, Path p_dirPickup, javax.mail.internet.InternetAddress p_addressFromFallback)
  • Method Details

    • setAutoCommit

      public void setAutoCommit(boolean p_bAutoCommit)
    • addHeader

      public void addHeader(String p_strName, String p_strValue)
    • hasRecipients

      public boolean hasRecipients()
    • hasRecipientsTo

      public boolean hasRecipientsTo()
    • hasRecipientsCc

      public boolean hasRecipientsCc()
    • hasRecipientsBcc

      public boolean hasRecipientsBcc()
    • hasRecipientsReplyTo

      public boolean hasRecipientsReplyTo()
    • addRecipient

      public void addRecipient(javax.mail.Message.RecipientType p_rcpType, String p_strAddress) throws javax.mail.internet.AddressException
      Throws:
      javax.mail.internet.AddressException - If the given address is not a valid Internet mail address.
      IllegalArgumentException - If p_strAddress is null or empty.
    • addRecipient

      public void addRecipient(javax.mail.Message.RecipientType p_rcpType, javax.mail.internet.InternetAddress p_address)
    • addRecipientTo

      public void addRecipientTo(String p_strAddress) throws javax.mail.internet.AddressException
      Throws:
      javax.mail.internet.AddressException
    • addRecipientTo

      public void addRecipientTo(javax.mail.internet.InternetAddress p_address)
    • addRecipientsTo

      public void addRecipientsTo(Collection<String> p_addresses) throws javax.mail.internet.AddressException
      Parameters:
      p_addresses - A collection of e-mail addresses.
      Throws:
      javax.mail.internet.AddressException - If the given address is not a valid Internet mail address.
    • addRecipientCc

      public void addRecipientCc(String p_strAddress) throws javax.mail.internet.AddressException
      Throws:
      javax.mail.internet.AddressException
    • addRecipientCc

      public void addRecipientCc(javax.mail.internet.InternetAddress p_address)
    • addRecipientsCc

      public void addRecipientsCc(Collection<String> p_addresses) throws javax.mail.internet.AddressException
      Parameters:
      p_addresses - A collection of e-mail addresses.
      Throws:
      javax.mail.internet.AddressException - If the given address is not a valid Internet mail address.
    • addRecipientBcc

      public void addRecipientBcc(String p_strAddress) throws javax.mail.internet.AddressException
      Throws:
      javax.mail.internet.AddressException
    • addRecipientBcc

      public void addRecipientBcc(javax.mail.internet.InternetAddress p_address)
    • addRecipientsBcc

      public void addRecipientsBcc(Collection<String> p_addresses) throws javax.mail.internet.AddressException
      Parameters:
      p_addresses - A collection of e-mail addresses.
      Throws:
      javax.mail.internet.AddressException - If the given address is not a valid Internet mail address.
    • addRecipientReplyTo

      public void addRecipientReplyTo(String p_strAddress) throws javax.mail.internet.AddressException
      Throws:
      javax.mail.internet.AddressException
    • addRecipientReplyTo

      public void addRecipientReplyTo(javax.mail.internet.InternetAddress p_address)
    • addRecipientsReplyTo

      public void addRecipientsReplyTo(Collection<String> p_addresses) throws javax.mail.internet.AddressException
      Parameters:
      p_addresses - A collection of e-mail addresses.
      Throws:
      javax.mail.internet.AddressException - If the given address is not a valid Internet mail address.
    • addRecipients

      public void addRecipients(javax.mail.Message.RecipientType p_rcpType, Collection<String> p_addresses) throws javax.mail.internet.AddressException
      Parameters:
      p_rcpType - The recipient type.
      p_addresses - A collection of mail addresses.
      Throws:
      javax.mail.internet.AddressException - If one of the given addresses is not a valid Internet mail address.
    • send

      public String send() throws javax.mail.MessagingException, IOException, InterruptedException
      This method creates a MIME message and stores the message as file in the pickup folder.
      Returns:
      The name of the mail file created.
      Throws:
      javax.mail.MessagingException
      IOException
      InterruptedException
    • create

      public Path create(String p_strFileName, Path p_dirTmp) throws javax.mail.MessagingException, IOException
      This method creates a MIME message and stores the message as file with the given name in the given directory.
      Parameters:
      p_strFileName - The file name.
      p_dirTmp - The directory whre the file sould be created.
      Returns:
      The mail file created.
      Throws:
      javax.mail.MessagingException
      IOException
    • commit

      public void commit() throws InterruptedException
      Throws:
      InterruptedException
    • rollback

      public void rollback()
    • setContent

      public void setContent(String p_strContent, String p_strContentType)
    • attachFile

      public void attachFile(de.uplanet.lucy.server.mail.AttachmentFile p_attachment)
    • attachFile

      public void attachFile(String p_strPath, String p_strFileName, String p_strContentType)
    • attachRelatedFile

      public void attachRelatedFile(String p_strPath, String p_strFileName, String p_strContentType, String p_strContentId)
    • attachRelatedFile

      public void attachRelatedFile(de.uplanet.lucy.server.mail.AttachmentFile p_attachment)
    • clearContentAndAttachments

      public void clearContentAndAttachments()
      Clears the content previously set with setContent(String, String) as well as all attachments.

      For internal use only.

    • setFrom

      public void setFrom(String p_strFrom) throws javax.mail.internet.AddressException
      Throws:
      javax.mail.internet.AddressException
    • setFrom

      public void setFrom(javax.mail.internet.InternetAddress p_addressFrom)
    • setSubject

      public void setSubject(String p_strSubject)
    • createClone

      public MailBuilder createClone()