diff --git a/src/java/davmail/exchange/ews/CopyItemMethod.java b/src/java/davmail/exchange/ews/CopyItemMethod.java index 1d0d7f8b..ceca95ba 100644 --- a/src/java/davmail/exchange/ews/CopyItemMethod.java +++ b/src/java/davmail/exchange/ews/CopyItemMethod.java @@ -18,6 +18,8 @@ */ package davmail.exchange.ews; +import java.util.List; + /** * Copy item to another folder. */ @@ -33,4 +35,17 @@ public class CopyItemMethod extends EWSMethod { this.itemId = itemId; this.toFolderId = toFolderId; } + + /** + * Copy items to target folder. + * + * @param itemIds item id list + * @param toFolderId target folder id + */ + public CopyItemMethod(List itemIds, FolderId toFolderId) { + super("Item", "CopyItem"); + this.itemIds = itemIds; + this.toFolderId = toFolderId; + } + } diff --git a/src/java/davmail/exchange/ews/EwsExchangeSession.java b/src/java/davmail/exchange/ews/EwsExchangeSession.java index 9aa58fb3..fad20447 100644 --- a/src/java/davmail/exchange/ews/EwsExchangeSession.java +++ b/src/java/davmail/exchange/ews/EwsExchangeSession.java @@ -1234,6 +1234,20 @@ public class EwsExchangeSession extends ExchangeSession { executeMethod(moveItemMethod); } + /** + * @inheritDoc + */ + @Override + public void moveMessages(List messages, String targetFolder) throws IOException { + ArrayList itemIds = new ArrayList(); + for (ExchangeSession.Message message: messages) { + itemIds.add(((EwsExchangeSession.Message) message).itemId); + } + + MoveItemMethod moveItemMethod = new MoveItemMethod(itemIds, getFolderId(targetFolder)); + executeMethod(moveItemMethod); + } + /** * @inheritDoc */ @@ -1243,6 +1257,20 @@ public class EwsExchangeSession extends ExchangeSession { executeMethod(copyItemMethod); } + /** + * @inheritDoc + */ + @Override + public void copyMessages(List messages, String targetFolder) throws IOException { + ArrayList itemIds = new ArrayList(); + for (ExchangeSession.Message message: messages) { + itemIds.add(((EwsExchangeSession.Message) message).itemId); + } + + CopyItemMethod copyItemMethod = new CopyItemMethod(itemIds, getFolderId(targetFolder)); + executeMethod(copyItemMethod); + } + /** * @inheritDoc */