MimeMessage extends Message implements MimePart { public synchronized void setDataHandler(DataHandler dh) throws MessagingException { this.dh = dh; cachedContent = null; MimeBodyPart.invalidateContentHeaders(this); } MimeMessage(Session session);  MimeMessage(Session session, InputStream is);  MimeMessage(MimeMessage source); protected  MimeMessage(Folder folder, int msgnum); protected  MimeMessage(Folder folder, InputStream is, int msgnum); protected  MimeMessage(Folder folder, InternetHeaders headers,
		byte[] content, int msgnum); Address[] getFrom(); void setFrom(Address address); void setFrom(String address); void setFrom(); void addFrom(Address[] addresses); Address getSender(); void setSender(Address address); Address[] getRecipients(Message.RecipientType type); Address[] getAllRecipients(); void setRecipients(Message.RecipientType type, Address[] addresses); void setRecipients(Message.RecipientType type, String addresses); void addRecipients(Message.RecipientType type, Address[] addresses); void addRecipients(Message.RecipientType type, String addresses); Address[] getReplyTo(); void setReplyTo(Address[] addresses); String getSubject(); void setSubject(String subject); void setSubject(String subject, String charset); Date getSentDate(); void setSentDate(Date d); Date getReceivedDate(); int getSize(); int getLineCount(); String getContentType(); boolean isMimeType(String mimeType); String getDisposition(); void setDisposition(String disposition); String getEncoding(); String getContentID(); void setContentID(String cid); String getContentMD5(); void setContentMD5(String md5); String getDescription(); void setDescription(String description); void setDescription(String description, String charset); String[] getContentLanguage(); void setContentLanguage(String[] languages); String getMessageID(); String getFileName(); void setFileName(String filename); InputStream getInputStream(); InputStream getRawInputStream(); synchronized DataHandler getDataHandler(); Object getContent(); synchronized void setDataHandler(DataHandler dh); void setContent(Object o, String type); void setText(String text); void setText(String text, String charset); void setText(String text, String charset, String subtype); void setContent(Multipart mp); Message reply(boolean replyToAll); Message reply(boolean replyToAll, boolean setAnswered); void writeTo(OutputStream os); void writeTo(OutputStream os, String[] ignoreList); String[] getHeader(String name); String getHeader(String name, String delimiter); void setHeader(String name, String value); void addHeader(String name, String value); void removeHeader(String name); Enumeration getAllHeaders(); Enumeration getMatchingHeaders(String[] names); Enumeration getNonMatchingHeaders(String[] names); void addHeaderLine(String line); Enumeration getAllHeaderLines(); Enumeration getMatchingHeaderLines(String[] names); Enumeration getNonMatchingHeaderLines(String[] names); synchronized Flags getFlags(); synchronized boolean isSet(Flags.Flag flag); synchronized void setFlags(Flags flag, boolean set); void saveChanges();  }
@Test public void testSetDataHandler() throws Exception { Session s = Session.getInstance(new Properties()); MimeMessage orig = createMessage(s); final DataHandler odh = orig.getDataHandler(); MimeMessage msg = new MimeMessage(s) { { dh = odh; } }; msg = new MimeMessage(msg); assertEquals("text/x-test", msg.getContentType()); assertEquals("quoted-printable", msg.getEncoding()); assertEquals("test message", getString(msg.getInputStream())); }