Class MimeMessageUtils

java.lang.Object
org.apache.commons.mail2.jakarta.util.MimeMessageUtils

public final class MimeMessageUtils extends Object
Creates MimeMessage instances and other helper methods.
Since:
1.3
  • Method Summary

    Modifier and Type
    Method
    Description
    static jakarta.mail.internet.MimeMessage
    createMimeMessage(jakarta.mail.Session session, byte[] source)
    Creates a MimeMessage.
    static jakarta.mail.internet.MimeMessage
    createMimeMessage(jakarta.mail.Session session, File source)
    Creates a MimeMessage.
    static jakarta.mail.internet.MimeMessage
    createMimeMessage(jakarta.mail.Session session, InputStream source)
    Creates a MimeMessage.
    static jakarta.mail.internet.MimeMessage
    createMimeMessage(jakarta.mail.Session session, String source)
    Creates a MimeMessage using the platform's default character encoding.
    static jakarta.mail.internet.MimeMessage
    createMimeMessage(jakarta.mail.Session session, Path source, OpenOption... options)
    Creates a MimeMessage.
    static void
    writeMimeMessage(jakarta.mail.internet.MimeMessage mimeMessage, File resultFile)
    Writes a MimeMessage into a file.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • createMimeMessage

      public static jakarta.mail.internet.MimeMessage createMimeMessage(jakarta.mail.Session session, byte[] source) throws jakarta.mail.MessagingException, IOException
      Creates a MimeMessage.
      Parameters:
      session - the mail session.
      source - the input data.
      Returns:
      the MimeMessage.
      Throws:
      jakarta.mail.MessagingException - creating the MimeMessage failed.
      IOException - creating the MimeMessage failed.
    • createMimeMessage

      public static jakarta.mail.internet.MimeMessage createMimeMessage(jakarta.mail.Session session, File source) throws jakarta.mail.MessagingException, IOException
      Creates a MimeMessage.
      Parameters:
      session - the mail session.
      source - the input data.
      Returns:
      the MimeMessage.
      Throws:
      jakarta.mail.MessagingException - creating the MimeMessage failed.
      IOException - creating the MimeMessage failed.
    • createMimeMessage

      public static jakarta.mail.internet.MimeMessage createMimeMessage(jakarta.mail.Session session, InputStream source) throws jakarta.mail.MessagingException
      Creates a MimeMessage.
      Parameters:
      session - the mail session.
      source - the input data.
      Returns:
      the MimeMessage.
      Throws:
      jakarta.mail.MessagingException - creating the MimeMessage failed.
    • createMimeMessage

      public static jakarta.mail.internet.MimeMessage createMimeMessage(jakarta.mail.Session session, Path source, OpenOption... options) throws jakarta.mail.MessagingException, IOException
      Creates a MimeMessage.
      Parameters:
      session - the mail session.
      source - the input data.
      options - options specifying how the file is opened.
      Returns:
      the MimeMessage.
      Throws:
      jakarta.mail.MessagingException - creating the MimeMessage failed.
      IOException - creating the MimeMessage failed.
    • createMimeMessage

      public static jakarta.mail.internet.MimeMessage createMimeMessage(jakarta.mail.Session session, String source) throws jakarta.mail.MessagingException, IOException
      Creates a MimeMessage using the platform's default character encoding.
      Parameters:
      session - the mail session.
      source - the input data.
      Returns:
      the MimeMessage.
      Throws:
      jakarta.mail.MessagingException - creating the MimeMessage failed.
      IOException - creating the MimeMessage failed.
    • writeMimeMessage

      public static void writeMimeMessage(jakarta.mail.internet.MimeMessage mimeMessage, File resultFile) throws jakarta.mail.MessagingException, IOException
      Writes a MimeMessage into a file.
      Parameters:
      mimeMessage - the MimeMessage to write.
      resultFile - the file containing the MimeMessage.
      Throws:
      jakarta.mail.MessagingException - accessing MimeMessage failed.
      IOException - writing the MimeMessage failed.