Mail Compact by lotus script

Dear Team,

We tried to below code for mail compact on behalf of users.

User self compact own mail box but in this code i m missing some but don’t know what is missing kindly help us.

Dim g_NotesSess As notessession

Dim g_NotesDBCurrent As notesdatabase

Dim g_CompVw As NotesView

Dim g_CurrDoc As NotesDocument

Dim g_username As notesname



Dim g_DBMailbox As notesdatabase

Dim g_NotesDBNames As notesdatabase

Dim g_NamesCompVw As NotesView

Dim g_NamesCurrDoc As NotesDocument



Dim Returned_Val As Variant

Dim g_MailDocCollect As NotesDocumentCollection

Set g_NotesSess = New notessession

Set g_username = New NotesName(g_NotesSess.UserName)



Set g_NotesDBCurrent = g_NotesSess.currentdatabase

Set g_NotesDBNames = New NotesDatabase( g_NotesDBCurrent.Server, "names.nsf" )



Set g_CompVw = g_NotesDBCurrent.GetView("AllCompactmails")

Call g_CompVw.Refresh

Set g_NamesCompVw = g_NotesDBNames.GetView("($VIMPeople)")

Call g_NamesCompVw.Refresh



Set g_CurrDoc = g_CompVw.GetDocumentByKey( g_username.Abbreviated , True)

Set g_NamesCurrDoc = g_NamesCompVw.GetDocumentByKey( g_username.Abbreviated, True)



If g_CurrDoc Is Nothing Then

	

	Set g_DBMailbox = New NotesDatabase(g_NotesDBCurrent.Server , g_NamesCurrDoc.MailFile(0) & ".nsf")

	Set g_MailDocCollect = g_DBMailbox.AllDocuments

	Returned_Val = Messagebox ( "Mailbox size = " & ((g_DBMailbox.Size)/1024)/1024 & "MB > Total Documents In Mailbox = " & g_MailDocCollect.Count & "> % Used = " & g_DBMailbox.PercentUsed, 0+64+0+0 , "Your Mailbox Info !" )

	

	Set g_CurrDoc = New notesdocument(g_NotesDBCurrent)

	g_CurrDoc.form = "FrmCompactUserMail"

	g_CurrDoc.ComUserName = g_username.Abbreviated

	g_CurrDoc.ComUserMailbox = g_NamesCurrDoc.MailFile(0) & ".nsf"

	Call g_CurrDoc.Save(True, False)

	Returned_Val = Messagebox ("Request to compact your mailbox has been submitted. Your mailbox will be compacted in 15 minutes time depending on the size of the mailbox. Do not access mailbox during this time." , 0+16+0+0 , "Attention Please")

	

Elseif Not g_CurrDoc Is Nothing Then

	Msgbox "Request to compact your mailbox has already been submitted."		

End If

Subject: Mail Compact by lotus script

All this code does is saves a document in a db that has the info of what mail db to compact. There must be a another agent processes these documents and issues a compact command

You left out some lines from the code you copied over

from here

http://www-10.lotus.com/ldd/nd6forum.nsf/d6091795dfaa5b1185256a7a0048a2d0/0e208d5f9d1cc507852579c200429977?OpenDocument

right before the save add

Dim delta As Long

delta = g_DBMailbox.Compact

Subject: RE: Mail Compact by lotus script

Thanks Barry for quick response, but when i use

right before the save add Dim delta As Long

delta = g_DBMailbox.Compact

so prompt message only local mail box is compact but i need on server

Subject: RE: Mail Compact by lotus script

That is because you are clicking the button on the local copy and are using current db. you are also doing the lookup in the names.nsf against the local db.if you want look at the ini mailserver anduse that to look at the servers address book and them use these fileds from the person doc mailserver and mailfile to then open the servers mail file.

Subject: RE: Mail Compact by lotus script

Dear Barry Shapiro,

I take the mail file and server by ini server using getEnviromentstring but same issues.

Can you help me how to remove this error.

Subject: RE: Mail Compact by lotus script

If your location document is local then the ini will point to the local copy. Step thru the code and see the values of the mail file that you are opening. You can hard code to one server that users have access to and do a lookup to that user person doc to get the users true mail server and mail file.

Subject: RE: Mail Compact by lotus script

Dear Barry,

Thank you very much for response but i had already tried to put it server name is hard code but get it same error.