Java Code Examples for javax.mail.internet.MimeBodyPart#setFileName()

The following examples show how to use javax.mail.internet.MimeBodyPart#setFileName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CoreEncoders.java    From http-builder-ng with Apache License 2.0 6 votes vote down vote up
private static MimeBodyPart part(final ChainedHttpConfig config, final MultipartContent.MultipartPart multipartPart) throws MessagingException {
    final MimeBodyPart bodyPart = new MimeBodyPart();
    bodyPart.setDisposition("form-data");

    if (multipartPart.getFileName() != null) {
        bodyPart.setFileName(multipartPart.getFileName());
        bodyPart.setHeader("Content-Disposition", format("form-data; name=\"%s\"; filename=\"%s\"", multipartPart.getFieldName(), multipartPart.getFileName()));

    } else {
        bodyPart.setHeader("Content-Disposition", format("form-data; name=\"%s\"", multipartPart.getFieldName()));
    }

    bodyPart.setDataHandler(new DataHandler(new EncodedDataSource(config, multipartPart.getContentType(), multipartPart.getContent())));
    bodyPart.setHeader("Content-Type", multipartPart.getContentType());

    return bodyPart;
}
 
Example 2
Source File: Mail.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private void addAttachedFilePart( FileObject file ) throws Exception {
  // create a data source

  MimeBodyPart files = new MimeBodyPart();
  // create a data source
  URLDataSource fds = new URLDataSource( file.getURL() );
  // get a data Handler to manipulate this file type;
  files.setDataHandler( new DataHandler( fds ) );
  // include the file in the data source
  files.setFileName( file.getName().getBaseName() );
  // insist on base64 to preserve line endings
  files.addHeader( "Content-Transfer-Encoding", "base64" );
  // add the part with the file in the BodyPart();
  data.parts.addBodyPart( files );
  if ( isDetailed() ) {
    logDetailed( BaseMessages.getString( PKG, "Mail.Log.AttachedFile", fds.getName() ) );
  }

}
 
Example 3
Source File: TestUtil.java    From DKIM-for-JavaMail with Apache License 2.0 6 votes vote down vote up
public static void addFileAttachment(Multipart mp, Object filename) throws MessagingException {

		if (filename==null) return;
		
		File f = new File((String) filename);
		if (!f.exists() || !f.canRead()) {
			msgAndExit("Cannot read attachment file "+filename+", sending stops");
		}

		MimeBodyPart mbp_file = new MimeBodyPart();
        FileDataSource fds = new FileDataSource(f);
        mbp_file.setDataHandler(new DataHandler(fds));
        mbp_file.setFileName(f.getName());

        mp.addBodyPart(mbp_file);        
    }
 
Example 4
Source File: GMailClient.java    From blynk-server with GNU General Public License v3.0 6 votes vote down vote up
private void attachCSV(Multipart multipart, QrHolder[] attachmentData) throws Exception {
    StringBuilder sb = new StringBuilder();
    for (QrHolder qrHolder : attachmentData) {
        sb.append(qrHolder.token)
        .append(",")
        .append(qrHolder.deviceId)
        .append(",")
        .append(qrHolder.dashId)
        .append("\n");
    }
    MimeBodyPart attachmentsPart = new MimeBodyPart();
    ByteArrayDataSource source = new ByteArrayDataSource(sb.toString(), "text/csv");
    attachmentsPart.setDataHandler(new DataHandler(source));
    attachmentsPart.setFileName("tokens.csv");

    multipart.addBodyPart(attachmentsPart);
}
 
Example 5
Source File: AccessStructure.java    From jplag with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @return A MimeMultipart object containing the zipped result files
 */
public MimeMultipart getResult() {

    File file = new File(JPLAG_RESULTS_DIRECTORY + File.separator
            + submissionID + getUsername() + ".zip");

    MimeMultipart mmp = new MimeMultipart();

    FileDataSource fds1 = new FileDataSource(file);
    MimetypesFileTypeMap mftp = new MimetypesFileTypeMap();
    mftp.addMimeTypes("multipart/zip zip ZIP");
    fds1.setFileTypeMap(mftp);

    MimeBodyPart mbp = new MimeBodyPart();

    try {
        mbp.setDataHandler(new DataHandler(fds1));
        mbp.setFileName(file.getName());

        mmp.addBodyPart(mbp);
    } catch (MessagingException me) {
        me.printStackTrace();
    }
    return mmp;
}
 
Example 6
Source File: HasAttachmentTest.java    From james-project with Apache License 2.0 5 votes vote down vote up
@Test
public void inlinedOnlyMultipartShouldNotBeMatched() throws Exception {
    MimeMultipart mimeMultipart = new MimeMultipart();
    MimeBodyPart part = new MimeBodyPart();
    part.setDisposition(MimeMessage.INLINE);
    part.setFileName("bahamas.png");
    mimeMultipart.addBodyPart(part);
    mimeMessage.setContent(mimeMultipart);

    assertThat(testee.match(mail)).isNull();
}
 
Example 7
Source File: MimeMessageHelper.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Add an attachment to the MimeMessage, taking the content from a
 * {@code javax.activation.DataSource}.
 * <p>Note that the InputStream returned by the DataSource implementation
 * needs to be a <i>fresh one on each call</i>, as JavaMail will invoke
 * {@code getInputStream()} multiple times.
 * @param attachmentFilename the name of the attachment as it will
 * appear in the mail (the content type will be determined by this)
 * @param dataSource the {@code javax.activation.DataSource} to take
 * the content from, determining the InputStream and the content type
 * @throws MessagingException in case of errors
 * @see #addAttachment(String, org.springframework.core.io.InputStreamSource)
 * @see #addAttachment(String, java.io.File)
 */
public void addAttachment(String attachmentFilename, DataSource dataSource) throws MessagingException {
	Assert.notNull(attachmentFilename, "Attachment filename must not be null");
	Assert.notNull(dataSource, "DataSource must not be null");
	try {
		MimeBodyPart mimeBodyPart = new MimeBodyPart();
		mimeBodyPart.setDisposition(MimeBodyPart.ATTACHMENT);
		mimeBodyPart.setFileName(MimeUtility.encodeText(attachmentFilename));
		mimeBodyPart.setDataHandler(new DataHandler(dataSource));
		getRootMimeMultipart().addBodyPart(mimeBodyPart);
	}
	catch (UnsupportedEncodingException ex) {
		throw new MessagingException("Failed to encode attachment filename", ex);
	}
}
 
Example 8
Source File: MimeMessageHelper.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Add an attachment to the MimeMessage, taking the content from a
 * {@code javax.activation.DataSource}.
 * <p>Note that the InputStream returned by the DataSource implementation
 * needs to be a <i>fresh one on each call</i>, as JavaMail will invoke
 * {@code getInputStream()} multiple times.
 * @param attachmentFilename the name of the attachment as it will
 * appear in the mail (the content type will be determined by this)
 * @param dataSource the {@code javax.activation.DataSource} to take
 * the content from, determining the InputStream and the content type
 * @throws MessagingException in case of errors
 * @see #addAttachment(String, org.springframework.core.io.InputStreamSource)
 * @see #addAttachment(String, java.io.File)
 */
public void addAttachment(String attachmentFilename, DataSource dataSource) throws MessagingException {
	Assert.notNull(attachmentFilename, "Attachment filename must not be null");
	Assert.notNull(dataSource, "DataSource must not be null");
	try {
		MimeBodyPart mimeBodyPart = new MimeBodyPart();
		mimeBodyPart.setDisposition(MimeBodyPart.ATTACHMENT);
		mimeBodyPart.setFileName(MimeUtility.encodeText(attachmentFilename));
		mimeBodyPart.setDataHandler(new DataHandler(dataSource));
		getRootMimeMultipart().addBodyPart(mimeBodyPart);
	}
	catch (UnsupportedEncodingException ex) {
		throw new MessagingException("Failed to encode attachment filename", ex);
	}
}
 
Example 9
Source File: MimeMultipartBuilder.java    From blackduck-alert with Apache License 2.0 5 votes vote down vote up
private void addAttachmentBodyParts(final MimeMultipart email) throws MessagingException {
    for (final String filePath : attachmentFilePaths) {
        final MimeBodyPart attachmentBodyPart = new MimeBodyPart();
        final DataSource source = new FileDataSource(filePath);
        attachmentBodyPart.setDataHandler(new DataHandler(source));
        attachmentBodyPart.setFileName(FilenameUtils.getName(filePath));
        email.addBodyPart(attachmentBodyPart);
    }
}
 
Example 10
Source File: MessageAlteringUtils.java    From james-project with Apache License 2.0 5 votes vote down vote up
private MimeBodyPart getErrorPart(Mail originalMail) throws MessagingException {
    MimeBodyPart errorPart = new MimeBodyPart();
    errorPart.setContent(originalMail.getErrorMessage(), "text/plain");
    errorPart.setHeader(RFC2822Headers.CONTENT_TYPE, "text/plain");
    errorPart.setFileName("Reasons");
    errorPart.setDisposition(javax.mail.Part.ATTACHMENT);
    return errorPart;
}
 
Example 11
Source File: MimeMessageBuilder.java    From james-project with Apache License 2.0 5 votes vote down vote up
public BodyPart build() throws IOException, MessagingException {
    Preconditions.checkState(!(dataAsString.isPresent() && dataAsBytes.isPresent()), "Can not specify data as bytes and data as string at the same time");
    MimeBodyPart bodyPart = new MimeBodyPart();
    if (dataAsBytes.isPresent()) {
        bodyPart.setDataHandler(
            new DataHandler(
                new ByteArrayDataSource(
                    dataAsBytes.get(),
                    type.orElse(DEFAULT_TEXT_PLAIN_UTF8_TYPE))
            ));
    } else {
        bodyPart.setDataHandler(
            new DataHandler(
                new ByteArrayDataSource(
                    dataAsString.orElse(DEFAULT_VALUE),
                    type.orElse(DEFAULT_TEXT_PLAIN_UTF8_TYPE))
            ));
    }
    if (filename.isPresent()) {
        bodyPart.setFileName(filename.get());
    }
    if (cid.isPresent()) {
        bodyPart.setContentID(cid.get());
    }
    if (disposition.isPresent()) {
        bodyPart.setDisposition(disposition.get());
    }
    List<Header> headerList = headers.build();
    for (Header header: headerList) {
        bodyPart.addHeader(header.name, header.value);
    }
    return bodyPart;
}
 
Example 12
Source File: Mail.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void addAttachedContent( String filename, String fileContent ) throws Exception {
  // create a data source

  MimeBodyPart mbp = new MimeBodyPart();
  // get a data Handler to manipulate this file type;
  mbp.setDataHandler( new DataHandler( new ByteArrayDataSource( fileContent.getBytes(), "application/x-any" ) ) );
  // include the file in the data source
  mbp.setFileName( filename );
  // add the part with the file in the BodyPart();
  data.parts.addBodyPart( mbp );

}
 
Example 13
Source File: MimeMessageHelper.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Add an attachment to the MimeMessage, taking the content from a
 * {@code javax.activation.DataSource}.
 * <p>Note that the InputStream returned by the DataSource implementation
 * needs to be a <i>fresh one on each call</i>, as JavaMail will invoke
 * {@code getInputStream()} multiple times.
 * @param attachmentFilename the name of the attachment as it will
 * appear in the mail (the content type will be determined by this)
 * @param dataSource the {@code javax.activation.DataSource} to take
 * the content from, determining the InputStream and the content type
 * @throws MessagingException in case of errors
 * @see #addAttachment(String, org.springframework.core.io.InputStreamSource)
 * @see #addAttachment(String, java.io.File)
 */
public void addAttachment(String attachmentFilename, DataSource dataSource) throws MessagingException {
	Assert.notNull(attachmentFilename, "Attachment filename must not be null");
	Assert.notNull(dataSource, "DataSource must not be null");
	try {
		MimeBodyPart mimeBodyPart = new MimeBodyPart();
		mimeBodyPart.setDisposition(MimeBodyPart.ATTACHMENT);
		mimeBodyPart.setFileName(MimeUtility.encodeText(attachmentFilename));
		mimeBodyPart.setDataHandler(new DataHandler(dataSource));
		getRootMimeMultipart().addBodyPart(mimeBodyPart);
	}
	catch (UnsupportedEncodingException ex) {
		throw new MessagingException("Failed to encode attachment filename", ex);
	}
}
 
Example 14
Source File: MailManager.java    From entando-components with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Add the attachments to the Multipart container.
 * @param attachmentFiles The attachments mapped as fileName/filePath.
 * @param multiPart The Multipart container.
 * @throws MessagingException In case of errors adding the attachments.
 */
protected void addAttachments(Properties attachmentFiles, Multipart multiPart) throws MessagingException {
	Iterator filesIter = attachmentFiles.entrySet().iterator();
	while (filesIter.hasNext()) {
		Entry fileEntry = (Entry) filesIter.next();
		MimeBodyPart fileBodyPart = new MimeBodyPart();
		DataSource dataSource = new FileDataSource((String) fileEntry.getValue());
		fileBodyPart.setDataHandler(new DataHandler(dataSource));
		fileBodyPart.setFileName((String) fileEntry.getKey());
		multiPart.addBodyPart(fileBodyPart);
	}
}
 
Example 15
Source File: MailUtil.java    From mail-micro-service with Apache License 2.0 5 votes vote down vote up
/**
 * 追加附件
 * @author hf-hf
 * @date 2018/12/27 16:53
 * @param attachments
 * @param wrapPart
 * @throws MessagingException
 * @throws UnsupportedEncodingException
 */
private void addAttachments(File[] attachments, MimeMultipart wrapPart)
        throws MessagingException, UnsupportedEncodingException {
    if (null != attachments && attachments.length > 0) {
        for (int i = 0; i < attachments.length; i++) {
            MimeBodyPart attachmentBodyPart = new MimeBodyPart();
            DataHandler dataHandler = new DataHandler(new FileDataSource(attachments[i]));
            String fileName = dataHandler.getName();
            attachmentBodyPart.setDataHandler(dataHandler);
            // 显示指定文件名(防止文件名乱码)
            attachmentBodyPart.setFileName(MimeUtility.encodeText(fileName));
            wrapPart.addBodyPart(attachmentBodyPart);
        }
    }
}
 
Example 16
Source File: EmailSender.java    From datacollector with Apache License 2.0 5 votes vote down vote up
public void send(List<String> addresses, String subject, String body, List<Attachment> attachments) throws EmailException {
  try {
    session = (session == null) ? createSession() : session;
    Message message = new MimeMessage(session);
    InternetAddress fromAddr = toAddress(from);
    message.setFrom(fromAddr);
    List<InternetAddress> toAddrs = toAddress(addresses);
    message.addRecipients(Message.RecipientType.TO, toAddrs.toArray(new InternetAddress[toAddrs.size()]));
    message.setSubject(subject);

    if(attachments != null && !attachments.isEmpty()) {
      MimeMultipart multipart = new MimeMultipart();
      MimeBodyPart htmlBodyPart = new MimeBodyPart();
      htmlBodyPart.setContent(body, "text/html; charset=UTF-8");
      multipart.addBodyPart(htmlBodyPart);

      for(Attachment attachment: attachments) {
        MimeBodyPart attachmentBodyPart = new MimeBodyPart();
        ByteArrayDataSource dataSource = new ByteArrayDataSource(attachment.getInputStream(), attachment.getContentType());
        attachmentBodyPart.setDataHandler(new DataHandler(dataSource));
        attachmentBodyPart.setFileName(attachment.getFilename());
        multipart.addBodyPart(attachmentBodyPart);
      }

      message.setContent(multipart);
    } else {
      message.setContent(body, "text/html; charset=UTF-8");
    }

    Transport transport = session.getTransport(protocol);
    if(auth) {
      transport.connect(host, user, password);
    } else {
      transport.connect(host, null, null);
    }
    transport.sendMessage(message, message.getAllRecipients());
    transport.close();
  } catch (Exception ex) {
    session = null;
    throw new EmailException(ex);
  }
}
 
Example 17
Source File: USERFRIENDLYSMTPNotifier.java    From juddi with Apache License 2.0 4 votes vote down vote up
@Override
public DispositionReport notifySubscriptionListener(NotifySubscriptionListener body) throws DispositionReportFaultMessage, RemoteException {

        try {
                log.info("Sending notification email to " + notificationEmailAddress + " from " + getEMailProperties().getProperty("mail.smtp.from", "jUDDI"));
                if (session != null && notificationEmailAddress != null) {
                        MimeMessage message = new MimeMessage(session);
                        InternetAddress address = new InternetAddress(notificationEmailAddress);
                        Address[] to = {address};
                        message.setRecipients(RecipientType.TO, to);
                        message.setFrom(new InternetAddress(getEMailProperties().getProperty("mail.smtp.from", "jUDDI")));
                        //maybe nice to use a template rather then sending raw xml.
                        String subscriptionResultXML = JAXBMarshaller.marshallToString(body, JAXBMarshaller.PACKAGE_SUBSCR_RES);
                        Multipart mp = new MimeMultipart();

                        MimeBodyPart content = new MimeBodyPart();
                        String msg_content = ResourceConfig.getGlobalMessage("notifications.smtp.userfriendly.body");

                        msg_content = String.format(msg_content,
                                StringEscapeUtils.escapeHtml(this.publisherName),
                                StringEscapeUtils.escapeHtml(AppConfig.getConfiguration().getString(Property.JUDDI_NODE_ID, "(unknown node id!)")),
                                GetSubscriptionType(body),
                                GetChangeSummary(body));

                        content.setContent(msg_content, "text/html; charset=UTF-8;");
                        mp.addBodyPart(content);

                        MimeBodyPart attachment = new MimeBodyPart();
                        attachment.setContent(subscriptionResultXML, "text/xml; charset=UTF-8;");
                        attachment.setFileName("uddiNotification.xml");
                        mp.addBodyPart(attachment);

                        message.setContent(mp);
                        message.setSubject(ResourceConfig.getGlobalMessage("notifications.smtp.userfriendly.subject") + " "
                                + body.getSubscriptionResultsList().getSubscription().getSubscriptionKey());
                        Transport.send(message);
                } else {
                        throw new DispositionReportFaultMessage("Session is null!", null);
                }
        } catch (Exception e) {
                log.error(e.getMessage(), e);
                throw new DispositionReportFaultMessage(e.getMessage(), null);
        }

        DispositionReport dr = new DispositionReport();
        Result res = new Result();
        dr.getResult().add(res);

        return dr;
}
 
Example 18
Source File: EmailLogServlet.java    From teamengine with Apache License 2.0 4 votes vote down vote up
public boolean sendLog(String host, String userId, String password,
        String to, String from, String subject, String message,
        File filename) {
    boolean success = true;
    System.out.println("host: " + host);
    System.out.println("userId: " + userId);
    // Fortify Mod: commented out clear text password.
    // System.out.println("password: " + password);
    System.out.println("to: " + to);
    System.out.println("from: " + from);
    System.out.println("subject: " + subject);
    System.out.println("message: " + message);
    System.out.println("filename: " + filename.getName());
    System.out.println("filename: " + filename.getAbsolutePath());

    // create some properties and get the default Session
    Properties props = System.getProperties();
    props.put("mail.smtp.host", host);
    props.put("mail.smtp.auth", "true");

    Session session = Session.getInstance(props, null);
    session.setDebug(true);

    try {
        // create a message
        MimeMessage msg = new MimeMessage(session);
        msg.setFrom(new InternetAddress(from));
        InternetAddress[] address = { new InternetAddress(to) };
        msg.setRecipients(Message.RecipientType.TO, address);
        msg.setSubject(subject);

        // create and fill the first message part
        MimeBodyPart mbp1 = new MimeBodyPart();
        mbp1.setText(message);

        // create the second message part
        MimeBodyPart mbp2 = new MimeBodyPart();

        // attach the file to the message
        FileDataSource fds = new FileDataSource(filename);
        mbp2.setDataHandler(new DataHandler(fds));
        mbp2.setFileName(fds.getName());

        // create the Multipart and add its parts to it
        Multipart mp = new MimeMultipart();
        mp.addBodyPart(mbp1);
        mp.addBodyPart(mbp2);

        // add the Multipart to the message
        msg.setContent(mp);

        // set the Date: header
        msg.setSentDate(new Date());

        // connect to the transport
        Transport trans = session.getTransport("smtp");
        trans.connect(host, userId, password);

        // send the message
        trans.sendMessage(msg, msg.getAllRecipients());

        // smtphost
        trans.close();

    } catch (MessagingException mex) {
        success = false;
        mex.printStackTrace();
        Exception ex = null;
        if ((ex = mex.getNextException()) != null) {
            ex.printStackTrace();
        }
    }
    return success;
}
 
Example 19
Source File: SesSendNotificationHandler.java    From smart-security-camera with GNU General Public License v3.0 4 votes vote down vote up
public Parameters handleRequest(Parameters parameters, Context context) {
	context.getLogger().log("Input Function [" + context.getFunctionName() + "], Parameters [" + parameters + "]");

	try {
		Session session = Session.getDefaultInstance(new Properties());
		MimeMessage message = new MimeMessage(session);
		message.setSubject(EMAIL_SUBJECT, "UTF-8");
		message.setFrom(new InternetAddress(System.getenv("EMAIL_FROM")));
		message.setReplyTo(new Address[] { new InternetAddress(System.getenv("EMAIL_FROM")) });
		message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(System.getenv("EMAIL_RECIPIENT")));

		MimeBodyPart wrap = new MimeBodyPart();
		MimeMultipart cover = new MimeMultipart("alternative");
		MimeBodyPart html = new MimeBodyPart();
		cover.addBodyPart(html);
		wrap.setContent(cover);
		MimeMultipart content = new MimeMultipart("related");
		message.setContent(content);
		content.addBodyPart(wrap);

		URL attachmentURL = new URL(
				System.getenv("S3_URL_PREFIX") + parameters.getS3Bucket() + '/' + parameters.getS3Key());

		StringBuilder sb = new StringBuilder();
		String id = UUID.randomUUID().toString();
		sb.append("<img src=\"cid:");
		sb.append(id);
		sb.append("\" alt=\"ATTACHMENT\"/>\n");

		MimeBodyPart attachment = new MimeBodyPart();
		DataSource fds = new URLDataSource(attachmentURL);
		attachment.setDataHandler(new DataHandler(fds));

		attachment.setContentID("<" + id + ">");
		attachment.setDisposition("attachment");

		attachment.setFileName(fds.getName());
		content.addBodyPart(attachment);

		String prettyPrintLabels = parameters.getRekognitionLabels().toString();
		prettyPrintLabels = prettyPrintLabels.replace("{", "").replace("}", "");
		prettyPrintLabels = prettyPrintLabels.replace(",", "<br>");
		html.setContent("<html><body><h2>Uploaded Filename : " + parameters.getS3Key().replace("upload/", "")
				+ "</h2><p><i>Step Function ID : " + parameters.getStepFunctionID()
				+ "</i></p><p><b>Detected Labels/Confidence</b><br><br>" + prettyPrintLabels + "</p>" + sb
				+ "</body></html>", "text/html");

		ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
		message.writeTo(outputStream);
		RawMessage rawMessage = new RawMessage(ByteBuffer.wrap(outputStream.toByteArray()));
		SendRawEmailRequest rawEmailRequest = new SendRawEmailRequest(rawMessage);

		AmazonSimpleEmailService client = AmazonSimpleEmailServiceClientBuilder.defaultClient();
		client.sendRawEmail(rawEmailRequest);

	// Convert Checked Exceptions to RuntimeExceptions to ensure that
	// they get picked up by the Step Function infrastructure
	} catch (MessagingException | IOException e) {
		throw new RuntimeException("Error in [" + context.getFunctionName() + "]", e);
	}

	context.getLogger().log("Output Function [" + context.getFunctionName() + "], Parameters [" + parameters + "]");

	return parameters;
}
 
Example 20
Source File: BigAttachmentTest.java    From subethasmtp with Apache License 2.0 4 votes vote down vote up
/** */
public void testAttachments() throws Exception
{
	if (BIGFILE_PATH.equals(TO_CHANGE))
	{
		log.error("BigAttachmentTest: To complete this test you must change the BIGFILE_PATH var to point out a file on your disk !");
	}
	assertNotSame("BigAttachmentTest: To complete this test you must change the BIGFILE_PATH var to point out a file on your disk !", TO_CHANGE, BIGFILE_PATH);
	Properties props = System.getProperties();
	props.setProperty("mail.smtp.host", "localhost");
	props.setProperty("mail.smtp.port", SMTP_PORT+"");
	Session session = Session.getInstance(props);

	MimeMessage baseMsg = new MimeMessage(session);
	MimeBodyPart bp1 = new MimeBodyPart();
	bp1.setHeader("Content-Type", "text/plain");
	bp1.setContent("Hello World!!!", "text/plain; charset=\"ISO-8859-1\"");

	// Attach the file
	MimeBodyPart bp2 = new MimeBodyPart();
	FileDataSource fileAttachment = new FileDataSource(BIGFILE_PATH);
	DataHandler dh = new DataHandler(fileAttachment);
	bp2.setDataHandler(dh);
	bp2.setFileName(fileAttachment.getName());

	Multipart multipart = new MimeMultipart();
	multipart.addBodyPart(bp1);
	multipart.addBodyPart(bp2);

	baseMsg.setFrom(new InternetAddress("Ted <[email protected]>"));
	baseMsg.setRecipient(Message.RecipientType.TO, new InternetAddress(
			"[email protected]"));
	baseMsg.setSubject("Test Big attached file message");
	baseMsg.setContent(multipart);
	baseMsg.saveChanges();

	log.debug("Send started");
	Transport t = new SMTPTransport(session, new URLName("smtp://localhost:"+SMTP_PORT));
	long started = System.currentTimeMillis();
	t.connect();
	t.sendMessage(baseMsg, new Address[] {new InternetAddress(
			"[email protected]")});
	t.close();
	started = System.currentTimeMillis() - started;
	log.info("Elapsed ms = "+started);

	WiserMessage msg = this.server.getMessages().get(0);

	assertEquals(1, this.server.getMessages().size());
	assertEquals("[email protected]", msg.getEnvelopeReceiver());

	File compareFile = File.createTempFile("attached", ".tmp");
	log.debug("Writing received attachment ...");

	FileOutputStream fos = new FileOutputStream(compareFile);
	((MimeMultipart) msg.getMimeMessage().getContent()).getBodyPart(1).getDataHandler().writeTo(fos);
	fos.close();
	log.debug("Checking integrity ...");
	assertTrue(this.checkIntegrity(new File(BIGFILE_PATH), compareFile));
	log.debug("Checking integrity DONE");
	compareFile.delete();
}