Search code examples
c#outlook-redemption

Move multiple mails to a folder in a different store


I'm using Outlook Redemption library (http://www.dimastr.com/redemption/home.htm) for my Outlook AddIn. I want to move multiple mails from an exchange account to a PST store.

onlineAccountFolder.Items.MoveMultiple(onlineEntryIds, targetFolderInPstStore);

The source folder mails were cut from the Exchange account, but not pasted in the target folder. They are gone.

I tried the same operation on an Exchange account folder in the same store and the move operation was successful. The items were moved to the target folder.

There's no overload of the 'MoveMultiple' method where I can define a StoreID.


Solution

  • I had no problem with the following script executed from OutlookSpy (I am its author - click “Script Editor” button on the OutlookSpy toolbar, paste the script, click Run.

    The script moves the messages selected in Outlook to a folder returned by the PickFolder method. Works as expected with both PST and Exchange target folders.

    set Session = CreateObject("Redemption.RDOSession")
    Session.MAPIOBJECT = Application.Session.MAPIOBJECT
    dim messages()
    set sel = Application.ActiveExplorer.Selection
    redim messages(sel.Count-1)
    for i = 1 to sel.Count
      messages(i-1) = sel.Item(i).EntryID
    next
    set targetFolder = Session.PickFolder
    set sourceFolder = Session.GetFolderFromID(Application.ActiveExplorer.CurrentFolder.EntryID)
    sourceFolder.Items.MoveMultiple messages, targetFolder