Package org.apache.commons.mail.util

# Class MimeMessageUtils

java.lang.Object
org.apache.commons.mail.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 MimeMessage`
  `createMimeMessage(Session session, byte[] source)`
  Creates a MimeMessage.
  `static MimeMessage`
  `createMimeMessage(Session session, File source)`
  Creates a MimeMessage.
  `static MimeMessage`
  `createMimeMessage(Session session, InputStream source)`
  Creates a MimeMessage.
  `static MimeMessage`
  `createMimeMessage(Session session, String source)`
  Creates a MimeMessage using the platform's default character encoding.
  `static MimeMessage`
  `createMimeMessage(Session session, Path source, OpenOption... options)`
  Creates a MimeMessage.
  `static void`
  `writeMimeMessage(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 MimeMessage createMimeMessage(Session session, byte[] source) throws MessagingException, IOException
    Creates a MimeMessage.
    Parameters:
      `session` - the mail session.
      `source` - the input data.
    Returns:
      the MimeMessage.
    Throws:
      `MessagingException` - creating the MimeMessage failed.
      `IOException` - creating the MimeMessage failed.

  - ### createMimeMessage

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

  - ### createMimeMessage

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

  - ### createMimeMessage

    public static MimeMessage createMimeMessage(Session session, Path source, OpenOption... options) throws 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:
      `MessagingException` - creating the MimeMessage failed.
      `IOException` - creating the MimeMessage failed.

  - ### createMimeMessage

    public static MimeMessage createMimeMessage(Session session, String source) throws 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:
      `MessagingException` - creating the MimeMessage failed.
      `IOException` - creating the MimeMessage failed.

  - ### writeMimeMessage

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