Empty an Office365 public folder containing 20.000 messages

SaintNick

New Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
It used to be possible with OWA to empty a public folder. That option is now gone.

MFCMAPI tool also can't open the PF store (MAPI_E_NOT_FOUND == 0x8004010F at CallOpenEntry).

Delete and recreate the folder is not an option because among other things it's email enabled, and it's a thing I need to do frequently.

Anyone else any idea's?

Powershell script maybe? Although that would be APITA because first I'd have to disable two-factor authentication in the admin center. (Powershell does not support 2F-authentication).
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Could you run a macro to empty it from one of the computers?

This might work, although it likely would need changed to count down...


Code:
Option Explicit
Public Sub DoSomethingFolder()
    Dim objOL As Outlook.Application
    Dim objItems As Outlook.Items
    Dim objFolder As Outlook.MAPIFolder

    Set objOL = Outlook.Application
    Set objFolder = objOL.ActiveExplorer.CurrentFolder
    Set objItems = objFolder.Items

Dim i As Long
  For i = objFolder.items.Count To 1 Step -1
  objFolder.items(i).Delete
  Next

  Set obj = Nothing
  Set objFolder = Nothing
  Set objOL = Nothing
End Sub
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Dang Enter key. :) Not only did i post it before it was finished, i also forgot a few lines. :)

The updated code above should delete all messages in the currently selected folder. It uses the macro at Working with All Items in a Folder or Selected Items as the base, but because it's deleting messages, you need to count backwards, otherwise you'll only delete every other one.
 
Top