Thanks for the quick reply.

I'm running into this now.

org.apache.commons.codec.DecoderException: Invalid URL encoding: not a
valid digit (radix 16): 117

from the following code:

BufferedReader reader = (BufferedReader) pop3.retrieveMessage(msginfo.number);
String line = "";
StringBuilder sb = new StringBuilder();
while ((line = reader.readLine()) != null) {
String lower = line.toLowerCase(Locale.ENGLISH);
sb.append(lower);
}

String msg=sb.toString();
byte[] bits;
try {
bits = 
org.apache.commons.codec.net.QuotedPrintableCodec.decodeQuotedPrintable(msg.getBytes("UTF8"));
msg = new String(bits, "UTF8");
} catch (Exception ex){//throw from here }


Any suggestions?


On Mon, Feb 3, 2014 at 11:51 AM, Thomas Neidhart
<thomas.neidh...@gmail.com> wrote:
> On 02/03/2014 05:48 PM, Alex O'Ree wrote:
>> I'm sending an email to a local mail server (hmail) using the standard
>> javax.mail api. Here's a snippit
>>
>> MimeMessage message = new MimeMessage(session);
>> InternetAddress address = new InternetAddress("receiver@local.domain");
>> Address[] to = {address};
>> message.setRecipients(RecipientType.TO, to);
>> message.setFrom("sender@local.domain");
>> String subscriptionResultXML = ""; //some raw xml goes here
>> message.setContent(subscriptionResultXML, "text/xml; charset=UTF-8;");
>> message.setSubject("subject");
>> Transport.send(message);
>>
>> When it sends, it appears to chop up the xml into roughly 80 chars,
>> adding a =\n (line break). The message is also flagged with
>> "quoted-printable" encoding with the following headers:
>> MIME-Version: 1.0
>> Content-Type: text/xml; charset=UTF-8;
>> Content-Transfer-Encoding: quoted-printable
>>
>> On the receiving side, I'm using the commons POP3 Client and I've been
>> struggling with how to decode the text. Basically, I need to remove
>> the =\n line breaks and end up with just the XML. I've tried using
>> javax.mail.internet.MimeUtility.decode....
>> BufferedReader reader = (BufferedReader) 
>> pop3.retrieveMessage(msginfo.number);
>> String line = "";
>> StringBuilder sb = new StringBuilder();
>> while ((line = reader.readLine()) != null) {
>>           String lower = line.toLowerCase(Locale.ENGLISH);
>>           sb.append(lower);
>> }
>>
>> String msg=sb.toString();
>> InputStream is = new ByteArrayInputStream(msg.getBytes("UTF8"));
>>  InputStream decode = javax.mail.internet.MimeUtility.decode(is,
>> "quoted-printable");
>> StringWriter writer = new StringWriter();
>> IOUtils.copy(decode, writer, "UTF8");
>> msg = writer.toString();
>>
>> However, I still end up with a string that includes the line encoding.
>> Interestingly enough, outlook seems to decode it just fine and renders
>> the xml as an attachment which is valid XML. Any ideas?
>
> you may take a look at commons-codec which contains an encoder/decoder
> for the quoted printable encoding:
>
> http://commons.apache.org/proper/commons-codec/archives/1.9/apidocs/org/apache/commons/codec/net/QuotedPrintableCodec.html
>
> Thomas
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
> For additional commands, e-mail: user-h...@commons.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org

Reply via email to