javax.mail.internet.MimeMessage.setDataHandler()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(9.2k)|赞(0)|评价(0)|浏览(155)

本文整理了Java中javax.mail.internet.MimeMessage.setDataHandler()方法的一些代码示例,展示了MimeMessage.setDataHandler()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MimeMessage.setDataHandler()方法的具体详情如下:
包路径:javax.mail.internet.MimeMessage
类名称:MimeMessage
方法名:setDataHandler

MimeMessage.setDataHandler介绍

[英]This method provides the mechanism to set this part's content. The given DataHandler object should wrap the actual content.
[中]此方法提供了设置此部件内容的机制。给定的DataHandler对象应该包装实际内容。

代码示例

代码示例来源:origin: stackoverflow.com

message.setSender(new InternetAddress(sender));   
message.setSubject(subject);   
message.setDataHandler(handler);   
if (recipients.indexOf(',') > 0)   
  message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(recipients));

代码示例来源:origin: stackoverflow.com

message.setSender(new InternetAddress(user));   
    message.setSubject(subject);   
    message.setDataHandler(handler);   
if (recipients.indexOf(',') > 0)   
  message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(recipients));

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * A convenience method for setting this Message's content. <p>
 *
 * The content is wrapped in a DataHandler object. Note that a
 * DataContentHandler class for the specified type should be
 * available to the JavaMail implementation for this to work right.
 * i.e., to do <code>setContent(foobar, "application/x-foobar")</code>,
 * a DataContentHandler for "application/x-foobar" should be installed.
 * Refer to the Java Activation Framework for more information.
 *
 * @param    o    the content object
 * @param    type    Mime type of the object
 * @exception       IllegalWriteException if the underlying
 *            implementation does not support modification of
 *            existing values
 * @exception    IllegalStateException if this message is
 *            obtained from a READ_ONLY folder.
 * @exception       MessagingException for other failures
 */
public void setContent(Object o, String type) 
    throws MessagingException {
if (o instanceof Multipart)
  setContent((Multipart)o);
else
  setDataHandler(new DataHandler(o, type));
}

代码示例来源:origin: com.sun.mail/javax.mail

/**
 * A convenience method for setting this Message's content. <p>
 *
 * The content is wrapped in a DataHandler object. Note that a
 * DataContentHandler class for the specified type should be
 * available to the JavaMail implementation for this to work right.
 * i.e., to do <code>setContent(foobar, "application/x-foobar")</code>,
 * a DataContentHandler for "application/x-foobar" should be installed.
 * Refer to the Java Activation Framework for more information.
 *
 * @param    o    the content object
 * @param    type    Mime type of the object
 * @exception       IllegalWriteException if the underlying
 *            implementation does not support modification of
 *            existing values
 * @exception    IllegalStateException if this message is
 *            obtained from a READ_ONLY folder.
 * @exception       MessagingException for other failures
 */
@Override
public void setContent(Object o, String type) 
    throws MessagingException {
if (o instanceof Multipart)
  setContent((Multipart)o);
else
  setDataHandler(new DataHandler(o, type));
}

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * This method sets the Message's content to a Multipart object.
 *
 * @param  mp      The multipart object that is the Message's content
 * @exception       IllegalWriteException if the underlying
 *            implementation does not support modification of
 *            existing values
 * @exception    IllegalStateException if this message is
 *            obtained from a READ_ONLY folder.
 * @exception       MessagingException for other failures
 */
public void setContent(Multipart mp) throws MessagingException {
setDataHandler(new DataHandler(mp, mp.getContentType()));
mp.setParent(this);
}

代码示例来源:origin: com.sun.mail/javax.mail

/**
 * This method sets the Message's content to a Multipart object.
 *
 * @param  mp      The multipart object that is the Message's content
 * @exception       IllegalWriteException if the underlying
 *            implementation does not support modification of
 *            existing values
 * @exception    IllegalStateException if this message is
 *            obtained from a READ_ONLY folder.
 * @exception       MessagingException for other failures
 */
@Override
public void setContent(Multipart mp) throws MessagingException {
setDataHandler(new DataHandler(mp, mp.getContentType()));
mp.setParent(this);
}

代码示例来源:origin: org.apache.james/james-server-core-library

/**
 * The message is changed when working with headers and when altering the content.
 * Every method that alter the content will fallback to this one.
 * 
 * @see javax.mail.Part#setDataHandler(javax.activation.DataHandler)
 */
public synchronized void setDataHandler(DataHandler arg0) throws MessagingException {
  modified = true;
  saved = false;
  bodyModified = true;
  super.setDataHandler(arg0);
}

代码示例来源:origin: org.apache.geronimo.specs/geronimo-javamail_1.4_spec

public void setContent(Object content, String type) throws MessagingException {
  setDataHandler(new DataHandler(content, type));
}

代码示例来源:origin: org.apache.geronimo.specs/geronimo-javamail_1.3.1_spec

public void setContent(Object content, String type) throws MessagingException {
  setDataHandler(new DataHandler(content, type));
}

代码示例来源:origin: org.apache.james/james-server-core-library

/**
 * @see javax.mail.Part#setDataHandler(javax.activation.DataHandler)
 */
public void setDataHandler(DataHandler dh) throws MessagingException {
  getWrappedMessageForWriting().setDataHandler(dh);
}

代码示例来源:origin: stackoverflow.com

File file = new File("huge-message.txt");
MimeMessage msg = new MimeMessage(mailSession);
msg.setFrom(...);
msg.setRecipient(...);
msg.setSubject(...);
msg.setDataHandler(new DataHandler(new FileDataSource(file)));

代码示例来源:origin: stackoverflow.com

MimeMessage message = new MimeMessage(session);
DataHandler handler = new DataHandler(new ByteArrayDataSource(body.getBytes(), "text/plain"));
message.setSender(new InternetAddress(sender));
message.setSubject(subject);
message.setDataHandler(handler);
message.setRecipient(Message.RecipientType.TO, new InternetAddress(recipients));
Transport.send(message);

代码示例来源:origin: org.apache.geronimo.specs/geronimo-javamail_1.3.1_spec

public void setContent(Multipart part) throws MessagingException {
  setDataHandler(new DataHandler(part, part.getContentType()));
  part.setParent(this);
}

代码示例来源:origin: org.apache.geronimo.specs/geronimo-javamail_1.4_spec

public void setContent(Multipart part) throws MessagingException {
  setDataHandler(new DataHandler(part, part.getContentType()));
  part.setParent(this);
}

代码示例来源:origin: javax.mail/javax.mail-api

/**
 * This method sets the Message's content to a Multipart object.
 *
 * @param  mp      The multipart object that is the Message's content
 * @exception       IllegalWriteException if the underlying
 *            implementation does not support modification of
 *            existing values
 * @exception    IllegalStateException if this message is
 *            obtained from a READ_ONLY folder.
 * @exception       MessagingException for other failures
 */
@Override
public void setContent(Multipart mp) throws MessagingException {
setDataHandler(new DataHandler(mp, mp.getContentType()));
mp.setParent(this);
}

代码示例来源:origin: javax.mail/com.springsource.javax.mail

/**
 * This method sets the Message's content to a Multipart object.
 *
 * @param  mp      The multipart object that is the Message's content
 * @exception       IllegalWriteException if the underlying
 *            implementation does not support modification of
 *            existing values
 * @exception    IllegalStateException if this message is
 *            obtained from a READ_ONLY folder.
 * @exception       MessagingException
 */
public void setContent(Multipart mp) throws MessagingException {
setDataHandler(new DataHandler(mp, mp.getContentType()));
mp.setParent(this);
}

代码示例来源:origin: org.apache.camel/camel-mail

protected String populateContentOnMimeMessage(MimeMessage part, MailConfiguration configuration, Exchange exchange)
  throws MessagingException, IOException {
  String contentType = determineContentType(configuration, exchange);
  LOG.trace("Using Content-Type {} for MimeMessage: {}", contentType, part);
  String body = exchange.getIn().getBody(String.class);
  if (body == null) {
    body = "";
  }
  // always store content in a byte array data store to avoid various content type and charset issues
  DataSource ds = new ByteArrayDataSource(body, contentType);
  part.setDataHandler(new DataHandler(ds));
  // set the content type header afterwards
  part.setHeader("Content-Type", contentType);
  return contentType;
}

代码示例来源:origin: jboss/jboss-javaee-specs

/**
 * This method sets the Message's content to a Multipart object.
 *
 * @param  mp      The multipart object that is the Message's content
 * @exception       IllegalWriteException if the underlying
 *            implementation does not support modification of
 *            existing values
 * @exception    IllegalStateException if this message is
 *            obtained from a READ_ONLY folder.
 * @exception       MessagingException for other failures
 */
@Override
public void setContent(Multipart mp) throws MessagingException {
setDataHandler(new DataHandler(mp, mp.getContentType()));
mp.setParent(this);
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.javax.mail

/**
 * This method sets the Message's content to a Multipart object.
 *
 * @param  mp      The multipart object that is the Message's content
 * @exception       IllegalWriteException if the underlying
 *            implementation does not support modification of
 *            existing values
 * @exception    IllegalStateException if this message is
 *            obtained from a READ_ONLY folder.
 * @exception       MessagingException
 */
public void setContent(Multipart mp) throws MessagingException {
setDataHandler(new DataHandler(mp, mp.getContentType()));
mp.setParent(this);
}

代码示例来源:origin: com.sun.mail/mailapi

/**
 * This method sets the Message's content to a Multipart object.
 *
 * @param  mp      The multipart object that is the Message's content
 * @exception       IllegalWriteException if the underlying
 *            implementation does not support modification of
 *            existing values
 * @exception    IllegalStateException if this message is
 *            obtained from a READ_ONLY folder.
 * @exception       MessagingException for other failures
 */
@Override
public void setContent(Multipart mp) throws MessagingException {
setDataHandler(new DataHandler(mp, mp.getContentType()));
mp.setParent(this);
}

相关文章

MimeMessage类方法