javax.mail.internet

Interface MimePart

  • All Superinterfaces:
    Part
    All Known Implementing Classes:
    MimeBodyPart, MimeMessage, PreencodedMimeBodyPart

    public interface MimePart
    extends Part
    The MimePart interface models an Entity as defined by MIME (RFC2045, Section 2.4).

    MimePart extends the Part interface to add additional RFC822 and MIME specific semantics and attributes. It provides the base interface for the MimeMessage and MimeBodyPart classes A note on RFC822 and MIME headers

    RFC822 and MIME header fields must contain only US-ASCII characters. If a header contains non US-ASCII characters, it must be encoded as per the rules in RFC 2047. The MimeUtility class provided in this package can be used to to achieve this. Callers of the setHeader, addHeader, and addHeaderLine methods are responsible for enforcing the MIME requirements for the specified headers. In addition, these header fields must be folded (wrapped) before being sent if they exceed the line length limitation for the transport (1000 bytes for SMTP). Received headers may have been folded. The application is responsible for folding and unfolding headers as appropriate.

    Author:
    John Mani
    See Also:
    MimeUtility, Part
    • Method Detail

      • getHeader

        String getHeader(String name,
                         String delimiter)
                  throws MessagingException
        Get the values of all header fields available for this header, returned as a single String, with the values separated by the delimiter. If the delimiter is null, only the first value is returned.
        Parameters:
        name - the name of this header
        delimiter - delimiter between fields in returned string
        Returns:
        the value fields for all headers with this name
        Throws:
        MessagingException
      • getAllHeaderLines

        Enumeration getAllHeaderLines()
                               throws MessagingException
        Get all header lines as an Enumeration of Strings. A Header line is a raw RFC822 header-line, containing both the "name" and "value" field.
        Throws:
        MessagingException
      • getMatchingHeaderLines

        Enumeration getMatchingHeaderLines(String[] names)
                                    throws MessagingException
        Get matching header lines as an Enumeration of Strings. A Header line is a raw RFC822 header-line, containing both the "name" and "value" field.
        Throws:
        MessagingException
      • getNonMatchingHeaderLines

        Enumeration getNonMatchingHeaderLines(String[] names)
                                       throws MessagingException
        Get non-matching header lines as an Enumeration of Strings. A Header line is a raw RFC822 header-line, containing both the "name" and "value" field.
        Throws:
        MessagingException
      • getContentLanguage

        String[] getContentLanguage()
                             throws MessagingException
        Get the language tags specified in the Content-Language header of this MimePart. The Content-Language header is defined by RFC 1766. Returns null if this header is not available.
        Throws:
        MessagingException
      • setContentLanguage

        void setContentLanguage(String[] languages)
                         throws MessagingException
        Set the Content-Language header of this MimePart. The Content-Language header is defined by RFC1766.
        Parameters:
        languages - array of language tags
        Throws:
        IllegalWriteException - if the underlying implementation does not support modification
        IllegalStateException - if this Part is obtained from a READ_ONLY folder
        MessagingException
      • setText

        void setText(String text)
              throws MessagingException
        Convenience method that sets the given String as this part's content, with a MIME type of "text/plain". If the string contains non US-ASCII characters. it will be encoded using the platform's default charset. The charset is also used to set the "charset" parameter.

        Note that there may be a performance penalty if text is large, since this method may have to scan all the characters to determine what charset to use.

        If the charset is already known, use the setText method that takes the charset parameter.

        Specified by:
        setText in interface Part
        Parameters:
        text - the text content to set
        Throws:
        MessagingException - if an error occurs
        See Also:
        setText(String text, String charset)
      • setText

        void setText(String text,
                     String charset)
              throws MessagingException
        Convenience method that sets the given String as this part's content, with a MIME type of "text/plain" and the specified charset. The given Unicode string will be charset-encoded using the specified charset. The charset is also used to set "charset" parameter.
        Parameters:
        text - the text content to set
        charset - the charset to use for the text
        Throws:
        MessagingException - if an error occurs
      • setText

        void setText(String text,
                     String charset,
                     String subtype)
              throws MessagingException
        Convenience method that sets the given String as this part's content, with a primary MIME type of "text" and the specified MIME subtype. The given Unicode string will be charset-encoded using the specified charset. The charset is also used to set the "charset" parameter.
        Parameters:
        text - the text content to set
        charset - the charset to use for the text
        subtype - the MIME subtype to use (e.g., "html")
        Throws:
        MessagingException - if an error occurs
        Since:
        JavaMail 1.4

Traduction non disponible

Les API Java ne sont pas encore traduites en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.

Version en cache

21/08/2025 15:07:10 Cette version de la page est en cache (à la date du 21/08/2025 15:07:10) afin d'accélérer le traitement.
Vous pouvez activer le mode utilisateur dans le menu en haut pour afficher la version plus récente de la page.

Document créé le 19/04/2008, dernière modification le 18/08/2025
Source du document imprimé : https://www.gaudry.be/java-api-javaee-rf-javax/mail/internet/MimePart.html

L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.

Références

  1. Consulter le document html Langue du document :fr Manuel PHP : https://docs.oracle.com, MimePart (Java(TM) EE 7 Specification APIs)

Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.