diff --git a/src/java/davmail/exchange/ExchangeSession.java b/src/java/davmail/exchange/ExchangeSession.java index 992c5bd0..e3800079 100644 --- a/src/java/davmail/exchange/ExchangeSession.java +++ b/src/java/davmail/exchange/ExchangeSession.java @@ -1458,6 +1458,12 @@ public class ExchangeSession { } } + /** + * Load message content in a Mime message + * @return mime message + * @throws IOException on error + * @throws MessagingException on error + */ public MimeMessage getMimeMessage() throws IOException, MessagingException { if (mimeMessage == null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); diff --git a/src/java/davmail/imap/ImapConnection.java b/src/java/davmail/imap/ImapConnection.java index 2d357121..1966b05a 100644 --- a/src/java/davmail/imap/ImapConnection.java +++ b/src/java/davmail/imap/ImapConnection.java @@ -679,15 +679,9 @@ public class ImapConnection extends AbstractConnection { protected void appendEnvelopeHeader(StringBuilder buffer, String[] value) { buffer.append(' '); if (value != null && value.length > 0) { - try { - buffer.append('"'); - // TODO: replace with MimeUtility.unfold - buffer.append(MimeUtility.decodeText(value[0]).replaceAll("\r\n", "")); - buffer.append('"'); - } catch (UnsupportedEncodingException e) { - DavGatewayTray.warn(e); - buffer.append("nil"); - } + buffer.append('"'); + buffer.append(MimeUtility.unfold(value[0])); + buffer.append('"'); } else { buffer.append("nil"); } @@ -703,7 +697,7 @@ public class ImapConnection extends AbstractConnection { buffer.append('('); String personal = address.getPersonal(); if (personal != null) { - buffer.append('"').append(personal).append('"'); + buffer.append('"').append(MimeUtility.encodeText(personal)).append('"'); } else { buffer.append("nil"); } @@ -723,6 +717,9 @@ public class ImapConnection extends AbstractConnection { } catch (AddressException e) { DavGatewayTray.warn(e); buffer.append("nil"); + } catch (UnsupportedEncodingException e) { + DavGatewayTray.warn(e); + buffer.append("nil"); } } else { buffer.append("nil");