Example usage for javax.mail.internet MimeUtility encodeText

List of usage examples for javax.mail.internet MimeUtility encodeText

Introduction

In this page you can find the example usage for javax.mail.internet MimeUtility encodeText.

Prototype

public static String encodeText(String text) throws UnsupportedEncodingException 

Source Link

Document

Encode a RFC 822 "text" token into mail-safe form as per RFC 2047.

Usage

From source file:org.wf.dp.dniprorada.util.Mail.java

public Mail _Attach(URL oURL, String sName) {
    try {//  ww w  . j a  v a 2 s .  com
        MimeBodyPart oMimeBodyPart = new MimeBodyPart();//javax.activation
        oMimeBodyPart.setHeader("Content-Type", "multipart/mixed");
        DataSource oDataSource = new URLDataSource(oURL);
        oMimeBodyPart.setDataHandler(new DataHandler(oDataSource));
        //oPart.setFileName(MimeUtility.encodeText(source.getName()));
        oMimeBodyPart.setFileName(
                MimeUtility.encodeText(sName == null || "".equals(sName) ? oDataSource.getName() : sName));
        oMultiparts.addBodyPart(oMimeBodyPart);
        log.info("[_Attach:oURL]:sName=" + sName);
    } catch (Exception oException) {
        log.error("[_Attach:oURL]:sName=" + sName, oException);
    }
    return this;
}