UTF-8 to Mail Header converter

Code courtesy Francis Devereux.
/*
 * RFC2047Example.java
 *
 * ©2008 Francis Devereux. All Rights Reserved
 */
// ---- Package ---------------------------------------------------------
package org.devrx.testpen.mail;

// ---- Import Statements -----------------------------------------------
import java.io.UnsupportedEncodingException;
import javax.mail.internet.MimeUtility;

/**
 * Demonstrates the use of JavaMail API to encode non-ASCII characters for
 * use in mail headers (e.g. subject lines).
 *
 * @author Francis Devereux
 */
public class RFC2047Example
{
    public static void main(String[] args)
        throws UnsupportedEncodingException
    {
        System.out.println(MimeUtility.encodeText(args[0], "UTF-8", null));
    }
}
      

Back to the UTF-8 to Mail Header converter ...

Syntax highlighter ©2004-2007 Alex Gorbatchev, homepage: http://code.google.com/p/syntaxhighlighter/