• Subject: Emptying items from a Shared mailbox's Inbox and any subfolders in it ..
  • Author: Thumper63
  • Date: 03 Nov 2009
  • References:
Hi All! Am an absolute newbie at this. I've spent quite a bit of time trying to work this out ... Here's what I've managed so far ... Any help surely appreciated here. Option Explicit Sub ClearOtherInbox() Dim objFolder As Outlook.Folder ' On Error Resume Next Set objFolder = GetOtherUserInbox("shared_mb@test.com") Call ProcessFolder(objFolder) End Sub Sub ProcessFolder(StartFolder As Outlook.Folder) ' Dim objFolder As Outlook.Folder ' On Error Resume Next ' process all the subfolders of this folder For Each StartFolder In StartFolder.Folders Call DeleteFolderItems(StartFolder) Next Set StartFolder = Nothing End Sub Sub DeleteFolderItems(foldar As Outlook.Folder) Dim colItems As Outlook.Items Dim longCount As Long Dim i As Long Set colItems = foldar.Items For i = longCount To 1 Step -1 colItems(i).Delete Next Set colItems = Nothing End Sub Function GetOtherUserInbox(strUserSMTP As String) As Folder Dim objOL As Outlook.Application Dim objNS As Outlook.NameSpace Dim objFolder As Outlook.Folder Dim objMsg As Outlook.MailItem Dim objRecip As Outlook.Recipient ' On Error Resume Next Set objOL = Application Set objNS = objOL.Session Set objRecip = objNS.CreateRecipient(strUserSMTP) Set objFolder = objNS.GetSharedDefaultFolder(objRecip, olFolderInbox) If objFolder Is Nothing Then MsgBox "Could not find Inbox for """ & _ strUserSMTP & """", vbExclamation, _ "User Not Found" End If Set GetOtherUserInbox = objFolder Set objFolder = Nothing Set objRecip = Nothing Set objMsg = Nothing Set objNS = Nothing Set objOL = Nothing End Function
03 Nov 2009Emptying items from a Shared mailbox's Inbox and any subfolders in it ...Thumper63
03 Nov 2009\ Re: Emptying items from a Shared mailbox's Inbox and any subfolders in it ...Sue Mosher [MVP]
Contact Us
All times are in (US) Eastern Daylight Time (GMT -4:00)