RE: Deleting 1 folder across multiple Mailboxes
- From: "Greg" <Greg@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 11 Jan 2006 15:31:02 -0800
I too am looking to delete about 30 folders that came over from a linux
migration and would love to find a way to script these folders away. There
are over 200 mailboxes that is a whole lot of click delete click delete.
Know what I am saying?
I found this script, but it seems to only work on Exchange 2000.
'================================================================================
' Copyright (c) 2005 Ted Crow, Information Technology Manager
' Tuttle Services, Inc. [ tedc@xxxxxxxxxxxxx / +1-419-228-6262 ]
'
' This file is provided free of charge and may be distributed freely so
' long as it is not modified in any way and this header remains completely
' intact.
'
'DISCLAIMER OF WARRANTY
' THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND WHETHER
' EXPRESSED OR IMPLIED. IN NO EVENT SHALL THE AUTHOR BE HELD LIABLE FOR ANY
' DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, DAMAGES FOR LOSS OF
BUSINESS
' PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS OR PERSONAL INFORMATION, OR
' ANY OTHER LOSS ARISING FROM THE USE OR INABILITY TO USE THE SOFTWARE.
'================================================================================
Option Explicit
Dim objCommand, objConnection, strBase, strFilter, strAttributes
Dim objSysInfo, strQuery, objRecordset, strName, strFolderName
Dim strServerName, strDomainDNSName, res, ShowConfirmation
strServerName = "mail server name"
strFolderName = "Spam"
strBase = "<LDAP://dc=mydomain,dc=com>"
ShowConfirmation = 1
'================================================================================
' YOU SHOULD NOT NEED TO EDIT ANYTHING BELOW THIS LINE!
'================================================================================
'Set objSysInfo = CreateObject("ADSystemInfo")
'strDomainDNSName = objSysInfo.DomainDNSName
Set objCommand = CreateObject("ADODB.Command")
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
objCommand.ActiveConnection = objConnection
strFilter = "(&(&(& (mailnickname=*) (|
(&(objectCategory=person)(objectClass=user)(|(homeMDB=*)(msExchHomeServerName=*))) ))))"
strAttributes = "sAMAccountName,cn"
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
objCommand.CommandText = strQuery
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Timeout") = 30
objCommand.Properties("Cache Results") = False
objCommand.Properties("Sort On") = "sAMAccountName"
Set objRecordSet = objCommand.Execute
Do Until objRecordSet.EOF
strName = objRecordSet.Fields("sAMAccountName").Value
res = DeleteFolderFromMailbox ( strServerName, strName, strFolderName )
objRecordSet.MoveNext
Loop
objConnection.Close
'================================================================================
' THE CORE OF THIS SCRIPT
'================================================================================
Function DeleteFolderFromMailbox(strServerName,strMailboxName,strFolderName)
On Error Resume Next
Dim objRecord, strObjectUrl, ConfirmDelete
ConfirmDelete = 7 'vbNo
Set objRecord = CreateObject("ADODB.Record")
' Specify the URL to the item to be deleted
strObjectUrl = "http://" & strServerName & "/exchange/" & strMailboxName &
"/" & strFolderName
'MsgBox "strObjectUrl : " & strObjectUrl
' Open the record
objRecord.Open strObjectUrl,,3 ' adModeReadWrite
If (Err.Number = 0) Then
If (ShowConfirmation = 1) Then
ConfirmDelete = MsgBox("Delete Folder '" & strFolderName & "' from
mailbox : " & strMailboxName & " (" & strServerName & ")",4,"Delete Folder")
Else
'MsgBox "DAV:href : " & objRecord.Fields("DAV:href")
ConfirmDelete = 6 ' vbYes
End If
' Delete the folder record
If (ConfirmDelete = 6) Then
objRecord.DeleteRecord
End If
End If
' Close the record and clean up
objRecord.Close
Set objRecord = Nothing
End Function
"Griff" wrote:
> We created a duplicate junk mail folder and want to delete it across multiple
> mailboxes. Is there a utility that will do this or do we need to open each
> mailbox individually? We have 1200 mailboxes.
> Thank you
.
- Follow-Ups:
- RE: Deleting 1 folder across multiple Mailboxes
- From: Griff
- RE: Deleting 1 folder across multiple Mailboxes
- Prev by Date: Re: Silly question...
- Next by Date: Re: bounced messages to Distribution Group
- Previous by thread: Re: Deleting 1 folder across multiple Mailboxes
- Next by thread: RE: Deleting 1 folder across multiple Mailboxes
- Index(es):
Relevant Pages
|