Example usage for javax.mail.internet ContentDisposition setDisposition

List of usage examples for javax.mail.internet ContentDisposition setDisposition

Introduction

In this page you can find the example usage for javax.mail.internet ContentDisposition setDisposition.

Prototype

public void setDisposition(String disposition) 

Source Link

Document

Set the disposition.

Usage

From source file:com.adaptris.mail.MailSenderImp.java

private void addAttachmentsToMessage(MimeMultipart multipart) throws MailException {
    try {//from  w  w  w  .  j a  v a  2  s  .c om
        for (Attachment a : attachments) {
            MimeBodyPart part = create(a.getBytes(), new InternetHeaders(), a.getEncoding());
            part.setHeader(Mail.CONTENT_TYPE, a.getContentType());
            ContentDisposition cd = new ContentDisposition();
            cd.setDisposition(Mail.DISPOSITION_TYPE_ATTACHMENT);
            if (a.getFilename() != null) {
                cd.setParameter(Mail.DISPOSITION_PARAM_FILENAME, a.getFilename());
            }
            part.setDisposition(cd.toString());
            multipart.addBodyPart(part);
        }
    } catch (Exception e) {
        throw new MailException(e);
    }
}