message.setSender(new InternetAddress(sender)); message.setSubject(subject); message.setDataHandler(handler); if (recipients.indexOf(',') > 0) message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(recipients));
message.setSender(new InternetAddress(user)); message.setSubject(subject); message.setDataHandler(handler); if (recipients.indexOf(',') > 0) message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(recipients));
/** * 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)); }
/** * 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)); }
/** * 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); }
/** * 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); }
/** * 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); }
public void setContent(Object content, String type) throws MessagingException { setDataHandler(new DataHandler(content, type)); }
public void setContent(Object content, String type) throws MessagingException { setDataHandler(new DataHandler(content, type)); }
/** * @see javax.mail.Part#setDataHandler(javax.activation.DataHandler) */ public void setDataHandler(DataHandler dh) throws MessagingException { getWrappedMessageForWriting().setDataHandler(dh); }
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)));
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);
public void setContent(Multipart part) throws MessagingException { setDataHandler(new DataHandler(part, part.getContentType())); part.setParent(this); }
public void setContent(Multipart part) throws MessagingException { setDataHandler(new DataHandler(part, part.getContentType())); part.setParent(this); }
/** * 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); }
/** * 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); }
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; }
/** * 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); }
/** * 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); }
/** * 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); }