MultipartReport (JavaMail API documentation)
Date: 2019-08-31

com.sun.mail.dsn

## Class MultipartReport

- java.lang.Object
- - javax.mail.Multipart
  - - javax.mail.internet.MimeMultipart
    - - com.sun.mail.dsn.MultipartReport

-     public class MultipartReport
      extends MimeMultipart

  A multipart/report message content, as defined in RFC 3462. A multipart/report content is a container for mail reports of any kind, and is most often used to return a delivery status report or a disposition notification report.

  A MultipartReport object is a special type of MimeMultipart object with a restricted set of body parts. A MultipartReport object contains:

  - [Required] A human readable text message describing the reason the report was generated.
  - [Required] A `Report` object containing the details for why the report was generated.
  - [Optional] A returned copy of the entire message, or just its headers, which caused the generation of this report.
  Many of the normal MimeMultipart operations are restricted to ensure that the MultipartReport object always follows this structure.
  Since:
    JavaMail 1.4

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected boolean` | `constructed`

    - ### Fields inherited from class javax.mail.internet.MimeMultipart

      `allowEmpty, complete, ds, ignoreExistingBoundaryParameter, ignoreMissingBoundaryParameter, ignoreMissingEndBoundary, parsed, preamble`

    - ### Fields inherited from class javax.mail.Multipart

      `contentType, parent, parts`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `MultipartReport()` Construct a multipart/report object with no content.
    `MultipartReport(javax.activation.DataSource ds)` Constructs a MultipartReport object and its bodyparts from the given DataSource.
    `MultipartReport(java.lang.String text, Report report)` Construct a multipart/report object with the specified plain text and report type (DeliveryStatus or DispositionNotification) to be returned to the user.
    `MultipartReport(java.lang.String text, Report report, InternetHeaders hdr)` Construct a multipart/report object with the specified plain text, report, and headers from the original message to be returned to the user.
    `MultipartReport(java.lang.String text, Report report, MimeMessage msg)` Construct a multipart/report object with the specified plain text, report, and original message to be returned to the user.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addBodyPart(BodyPart part)` Adds a Part to the multipart.
    `void` | `addBodyPart(BodyPart part, int index)` Adds a BodyPart at position `index`.
    `DeliveryStatus` | `getDeliveryStatus()` Deprecated. use getReport instead
    `Report` | `getReport()` Get the report associated with this multipart/report.
    `MimeMessage` | `getReturnedMessage()` Get the original message that is being returned along with this multipart/report.
    `java.lang.String` | `getText()` Get the plain text to be presented to the user, if there is any.
    `MimeBodyPart` | `getTextBodyPart()` Return the body part containing the message to be presented to the user, usually just a text/plain part.
    `boolean` | `removeBodyPart(BodyPart part)` Remove the specified part from the multipart message.
    `void` | `removeBodyPart(int index)` Remove the part at specified location (starting from 0).
    `void` | `setDeliveryStatus(DeliveryStatus status)` Deprecated. use setReport instead
    `void` | `setReport(Report report)` Set the report associated with this multipart/report.
    `void` | `setReturnedMessage(MimeMessage msg)` Set the original message to be returned as part of the multipart/report.
    `void` | `setSubType(java.lang.String subtype)` Set the subtype.
    `void` | `setText(java.lang.String text)` Set the message to be presented to the user as just a text/plain part containing the specified text.
    `void` | `setTextBodyPart(MimeBodyPart mbp)` Set the body part containing the text to be presented to the user.

    - ### Methods inherited from class javax.mail.internet.MimeMultipart

      `createInternetHeaders, createMimeBodyPart, createMimeBodyPart, getBodyPart, getBodyPart, getCount, getPreamble, initializeProperties, isComplete, parse, setPreamble, updateHeaders, writeTo`

    - ### Methods inherited from class javax.mail.Multipart

      `getContentType, getParent, setMultipartDataSource, setParent`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### constructed

          protected boolean constructed

  - ### Constructor Detail

    - #### MultipartReport

          public MultipartReport()
                          throws MessagingException

      Construct a multipart/report object with no content.
      Throws:
        `MessagingException`

    - #### MultipartReport

          public MultipartReport(java.lang.String text,
                                 Report report)
                          throws MessagingException

      Construct a multipart/report object with the specified plain text and report type (DeliveryStatus or DispositionNotification) to be returned to the user.
      Throws:
        `MessagingException`

    - #### MultipartReport

          public MultipartReport(java.lang.String text,
                                 Report report,
                                 MimeMessage msg)
                          throws MessagingException

      Construct a multipart/report object with the specified plain text, report, and original message to be returned to the user.
      Throws:
        `MessagingException`

    - #### MultipartReport

          public MultipartReport(java.lang.String text,
                                 Report report,
                                 InternetHeaders hdr)
                          throws MessagingException

      Construct a multipart/report object with the specified plain text, report, and headers from the original message to be returned to the user.
      Throws:
        `MessagingException`

    - #### MultipartReport

          public MultipartReport(javax.activation.DataSource ds)
                          throws MessagingException

      Constructs a MultipartReport object and its bodyparts from the given DataSource.

      Parameters:
        `ds` - DataSource, can be a MultipartDataSource
      Throws:
        `MessagingException`

  - ### Method Detail

    - #### getText

          public java.lang.String getText()
                                   throws MessagingException

      Get the plain text to be presented to the user, if there is any. Rarely, the message may contain only HTML text, or no text at all. If the text body part of this multipart/report object is of type text/plain, or if it is of type multipart/alternative and contains a text/plain part, the text from that part is returned. Otherwise, null is return and the `getTextBodyPart` method may be used to extract the data.
      Throws:
        `MessagingException`

    - #### setText

          public void setText(java.lang.String text)
                       throws MessagingException

      Set the message to be presented to the user as just a text/plain part containing the specified text.
      Throws:
        `MessagingException`

    - #### getTextBodyPart

          public MimeBodyPart getTextBodyPart()
                                       throws MessagingException

      Return the body part containing the message to be presented to the user, usually just a text/plain part.
      Throws:
        `MessagingException`

    - #### setTextBodyPart

          public void setTextBodyPart(MimeBodyPart mbp)
                               throws MessagingException

      Set the body part containing the text to be presented to the user. Usually this a text/plain part, but it might also be a text/html part or a multipart/alternative part containing text/plain and text/html parts. Any type is allowed here but these types are most common.
      Throws:
        `MessagingException`

    - #### getReport

          public Report getReport()
                           throws MessagingException

      Get the report associated with this multipart/report.
      Throws:
        `MessagingException`
      Since:
        JavaMail 1.4.2

    - #### setReport

          public void setReport(Report report)
                         throws MessagingException

      Set the report associated with this multipart/report.
      Throws:
        `MessagingException`
      Since:
        JavaMail 1.4.2

    - #### getDeliveryStatus

          public DeliveryStatus getDeliveryStatus()
                                           throws MessagingException

      Deprecated. use getReport instead
      Get the delivery status associated with this multipart/report.
      Throws:
        `MessagingException`

    - #### setDeliveryStatus

          public void setDeliveryStatus(DeliveryStatus status)
                                 throws MessagingException

      Deprecated. use setReport instead
      Set the delivery status associated with this multipart/report.
      Throws:
        `MessagingException`

    - #### getReturnedMessage

          public MimeMessage getReturnedMessage()
                                         throws MessagingException

      Get the original message that is being returned along with this multipart/report. If no original message is included, null is returned. In some cases only the headers of the original message will be returned as an object of type MessageHeaders.
      Throws:
        `MessagingException`

    - #### setReturnedMessage

          public void setReturnedMessage(MimeMessage msg)
                                  throws MessagingException

      Set the original message to be returned as part of the multipart/report. If msg is null, any previously set returned message or headers is removed.
      Throws:
        `MessagingException`

    - #### setSubType

          public void setSubType(java.lang.String subtype)
                          throws MessagingException

      Set the subtype. Throws MessagingException.
      Overrides:
        `setSubType` in class `MimeMultipart`
      Parameters:
        `subtype` - Subtype
      Throws:
        `MessagingException` - always; can't change subtype

    - #### removeBodyPart

          public boolean removeBodyPart(BodyPart part)
                                 throws MessagingException

      Remove the specified part from the multipart message. Not allowed on a multipart/report object.
      Overrides:
        `removeBodyPart` in class `MimeMultipart`
      Parameters:
        `part` - The part to remove
      Returns:
        true if part removed, false otherwise
      Throws:
        `MessagingException` - always

    - #### removeBodyPart

          public void removeBodyPart(int index)
                              throws MessagingException

      Remove the part at specified location (starting from 0). Not allowed on a multipart/report object.
      Overrides:
        `removeBodyPart` in class `MimeMultipart`
      Parameters:
        `index` - Index of the part to remove
      Throws:
        `MessagingException` - always

    - #### addBodyPart

          public void addBodyPart(BodyPart part)
                           throws MessagingException

      Adds a Part to the multipart. Not allowed on a multipart/report object.
      Overrides:
        `addBodyPart` in class `MimeMultipart`
      Parameters:
        `part` - The Part to be appended
      Throws:
        `MessagingException` - always

    - #### addBodyPart

          public void addBodyPart(BodyPart part,
                                  int index)
                           throws MessagingException

      Adds a BodyPart at position `index`. Not allowed on a multipart/report object.
      Overrides:
        `addBodyPart` in class `MimeMultipart`
      Parameters:
        `part` - The BodyPart to be inserted
        `index` - Location where to insert the part
      Throws:
        `MessagingException` - always

Copyright © 1996-2013, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms< /a>.