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