[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Unable to delete email from trash

Posted on 2009-04-29
3
Medium Priority
?
587 Views
Last Modified: 2013-12-18
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

0
Comment
Question by:Hoboly
  • 2
3 Comments
 
LVL 46

Accepted Solution

by:
Sjef Bosman earned 2000 total points
ID: 24267684
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
 

Author Closing Comment

by:Hoboly
ID: 31576305
Thanks!

what is Call dc.AutoUpdate= False, by the way?
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 24268393
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

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is about my first experience with programming Arduino.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Simple Linear Regression
Introduction to Processes

868 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question