diff --git a/src/java/davmail/exchange/dav/DavExchangeSession.java b/src/java/davmail/exchange/dav/DavExchangeSession.java index 37d01f27..ef3d9259 100644 --- a/src/java/davmail/exchange/dav/DavExchangeSession.java +++ b/src/java/davmail/exchange/dav/DavExchangeSession.java @@ -2548,8 +2548,17 @@ public class DavExchangeSession extends ExchangeSession { */ @Override public void copyMessage(ExchangeSession.Message message, String targetFolder) throws IOException { + try { + copyMessage(message.permanentUrl, targetFolder); + } catch (HttpNotFoundException e) { + LOGGER.debug("404 not found at permanenturl: " + message.permanentUrl + ", retry with messageurl"); + copyMessage(message.messageUrl, targetFolder); + } + } + + protected void copyMessage(String sourceUrl, String targetFolder) throws IOException { String targetPath = URIUtil.encodePath(getFolderPath(targetFolder)) + '/' + UUID.randomUUID().toString(); - CopyMethod method = new CopyMethod(message.permanentUrl, targetPath, false); + CopyMethod method = new CopyMethod(sourceUrl, targetPath, false); // allow rename if a message with the same name exists method.addRequestHeader("Allow-Rename", "t"); try { diff --git a/src/java/davmail/http/DavGatewayHttpClientFacade.java b/src/java/davmail/http/DavGatewayHttpClientFacade.java index fc7081dc..cb26da8d 100644 --- a/src/java/davmail/http/DavGatewayHttpClientFacade.java +++ b/src/java/davmail/http/DavGatewayHttpClientFacade.java @@ -36,6 +36,7 @@ import org.apache.commons.httpclient.util.IdleConnectionTimeoutThread; import org.apache.commons.httpclient.util.URIUtil; import org.apache.jackrabbit.webdav.DavException; import org.apache.jackrabbit.webdav.MultiStatusResponse; +import org.apache.jackrabbit.webdav.client.methods.CopyMethod; import org.apache.jackrabbit.webdav.client.methods.DavMethodBase; import org.apache.jackrabbit.webdav.client.methods.PropFindMethod; import org.apache.jackrabbit.webdav.property.DavPropertyNameSet; @@ -638,6 +639,9 @@ public final class DavGatewayHttpClientFacade { message.append(status).append(' ').append(method.getStatusText()); try { message.append(" at ").append(method.getURI().getURI()); + if (method instanceof CopyMethod) { + message.append(" to ").append(method.getRequestHeader("Destination")); + } } catch (URIException e) { message.append(method.getPath()); }