Unable to delete email from trash

attached the source code in vb.net 2003 calling lotus domino 6.5.4

no errors...

Thanks for help~
Public Function emptyTrash()
        open()
        Dim nDateTime As NotesDateTime = domS.CreateDateTime("")
        nDateTime.SetNow()
        nDateTime.AdjustMinute(DETECT_EMAIL_WITHIN_MIN)
 
        Dim dc As NotesView = domDB.GetView("($Trash)")
        Call domDB.EnableFolder("$Trash)")
 
        Dim dViewEntry As NotesViewEntryCollection = dc.AllEntries
        Dim counter As Integer
        Dim dEntry As NotesViewEntry
        Dim dDoc As NotesDocument
 
        For counter = 1 To dViewEntry.Count
 
            dEntry = dViewEntry.GetNthEntry(counter)
            dDoc = dEntry.Document
            ' If dDoc.DeliveredDate(0) < nDateTime.LSLocalTime Then
            dDoc.RemoveFromFolder("($Trash)")
            dDoc.Remove(True)
            'End If
 
        Next
 
        Call dc.Refresh()
 
 
        'Dim dc As NotesDocumentCollection = domDB.Search("VIEW = (\$Trash)", nDateTime, 0)
        'Dim domDoc As NotesDocument = dc.GetFirstDocument
        'Dim domDocDel As NotesDocument
        'While Not (domDoc Is Nothing)
        '    domDocDel = Nothing
        '    domDocDel = domDoc
        '    domDoc = dc.GetNextDocument(domDoc)
        '    If domDocDel Is Nothing = False Then
        '        domDocDel.RemoveFromFolder("($Trash)")
        '    End If
 
        'End While
 
        nDateTime = Nothing
        dc = Nothing
        domDocDel = Nothing
        domDoc = Nothing
 
        close()
    End Function

Open in new window

HobolyAsked:
Who is Participating?
 
Sjef BosmanGroupware ConsultantCommented:
On line 8, there's a left parenthesis missing, but that's not the problem.

Read the Help database on the Remove method. There you'll find this:
"This method does a soft deletion if "Allow soft deletions" is enabled. See RemovePermanently to do a hard deletion."

Finally, I'd never use a viewentry collection, just the view itself. Since you used dc for the view, this would be my code:

Dim nDoc As NotesDocument
Call dc.AutoUpdate= False
Set dDoc= dc.GetFirstDocument
Do Until dDoc is Nothing
      Set nDoc= dc.GetNextDocument(dDoc)
      Call dDoc.RemovePermanently(True)
      Set dDoc= nDoc
Loop
0
 
HobolyAuthor Commented:
Thanks!

what is Call dc.AutoUpdate= False, by the way?
0
 
Sjef BosmanGroupware ConsultantCommented:
Well... actually, it's plain wrong :-)  It should have been

      dc.AutoUpdate= False

It prevents the view from updating itself while you're using it. Updating is a waste of time, you're going to delete all documents in it anyway.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.