Purge a Mailbox from Exchange2003 programatically using C# or VB.net

HI experts

How do purge a mailbox of a user (not disabe) from Exchange server 2003 programatically using C# or VB.net

I am able to disable the Exchange mailbox of a user using the code below ..I added the referance CDOEXM to code

                        Try
                                UserMailbox = ObjExchange.NativeObject
                                UserMailbox.DeleteMailbox()
                                ObjExchange.CommitChanges()
                                MbxDel = "Deleted"
                            Catch ex As Exception
                                MbxDel = "Error"
                                MbxDelErr = ex.Message
                            End Try

After doing lot of google ...i came to know that Purge() will delete the user mailbox perminently from Exchange Server 2003
 so i tried the below  code ...its not working

                        Try
                                UserMailbox = ObjExchange.NativeObject
                                UserMailbox.Purge() 'Delete mailBox
                                ObjExchange.CommitChanges()
                                MbxDel = "Purged"
                            Catch ex As Exception
                                MbxDel = "Error"
                                MbxDelErr = ex.Message
                            End Try

Its not doing any thing...can any one plz help me ....
bobby010606Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RameshSCommented:

Try Exchange_Mailbox WMI class which has properties that return information about Microsoft Exchange mailboxes. The Purge method of this class removes the mailbox from the store permanently.
0
RameshSCommented:
The documentation of the Purge method in  Exchange_Mailbox WMI class says that the method is available only if the mailbox is disconnected.

Also check the following links.

How to selectively purge mailboxes using a script (Exchange 2003) – Another go

Reporting on Disconnected mailboxes and showing when they will be purged in Exchange 2003
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bobby010606Author Commented:
Tankx ramesh ...plz give me some time i will get back u
0
MegaNuk3Commented:
Here is some simple code to purge a selected disconnected(already deleted) mailbox.

' From the book "Active Directory, Third Edition" 
' ISBN: 0-596-10173-2

' This code purges a deleted mailbox.
Option Explicit
Dim strComputer, strMailbox, objWMI, objDiscMbx, objMbx
' ------ SCRIPT CONFIGURATION ------
strComputer = "<Exchange Server>" 'e.g. ExchServer2
strMailbox = "<Mailbox display name>"    'e.g. "Test, User"
' ------ END CONFIGURATION ---------

set objWMI = GetObject("winmgmts:\\" & strComputer & _
                       "\root\MicrosoftExchangeV2")
set objDiscMbx = objWMI.ExecQuery("Select * from Exchange_Mailbox WHERE " _
                              & "MailboxDisplayName='" & strMailbox & "'",,48)
for each objMbx in objDiscMbx
  objMbx.Purge
next
Wscript.Echo "Successfully purged mailbox."

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.