Unable to delete email from trash

Posted on 2009-04-29
Last Modified: 2013-12-18
attached the source code in 2003 calling lotus domino 6.5.4

no errors...

Thanks for help~
Public Function emptyTrash()


        Dim nDateTime As NotesDateTime = domS.CreateDateTime("")




        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



            'End If




        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



    End Function

Open in new window

Question by:Hoboly
    LVL 46

    Accepted Solution

    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

    Author Closing Comment


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

    Expert Comment

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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Suggested Solutions

    Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
    If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    759 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

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now