×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Delete document from agent

Delete document from agent

Delete document from agent

(OP)
I am new to lotusscript but I have cobbled together some code which allows me to open an existing mail and forward it to another mailbox. I then want to be able to mark the original mail document as deleted (but not actually delete it). This is where I am stuck. Whats the correct lotusscript command(s) to use for this? I run the agent manually from the actions menu after selecting the mail to work on from the inbox, if that makes any difference.

Thanks in advance.

RE: Delete document from agent

There are several ways to delete the document.  It depends on how you are accessing the document you want to delete.  If it is a NotesUIDocument the command would be

uidoc.deletedocument  - The document is not actually deleted from the database until the user refreshes the view or closes the database, and chooses to delete the marked document.
If the current document is already marked for deletion, this method closes the document, leaving the deletion mark in place.

If it is a NotesDocument then the command would be Remove.

Why do you have to open the document first?  Why not just send it without opening it?  That way everything is done from the view (or notesdocumentcollection).  Feel free to ask any questions.

Good Luck!

Leslie
landrews@metrocourt.state.nm.us

SELECT * FROM USERS WHERE CLUE > 0
No Rows Returned

RE: Delete document from agent

(OP)
Thanks for replying Leslie. An explanation is in order. We have an External AntiSpam system setup which passes any mails that it thinks are spam to a notes mailbox. I regularly go through this mailbox and if I find mails that are legitimate, I want to be able to pass them on to the original intended recipient, without losing their ability to reply to sender. The agent below runs from the actions menu on a selected mail document and keeps the from field as it should have been. The script works fine, except that I want to mark the ones that I have forwarded as deleted, but I dont want to actually delete them until I am happy that they have been received ok (maybe after a day or week). The last two lines commented out didn't work (error popup= Object variable not set).

If you can give some assistance, it would be great.

{Declarations section}
Dim maildb As NotesDatabase
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim newdoc As NotesDocument
Dim dc As notesdocumentcollection

{Initialize section}
Sub Initialize
    Dim session As New NotesSession
    Dim workspace As New NotesUIWorkspace
    Dim uidoc As NotesUIDocument
    Set db = session.CurrentDatabase
    Set dc = db.unprocesseddocuments
    servername=Evaluate("@subset(@maildbname;1)")
    Set maildb=session.getdatabase(servername(0),"Mail1.box")
    If Not maildb.isopen Then
        Set maildb=session.getdatabase(servername(0), "Mail2.box")
    End If
    If Not maildb.isopen Then
        Set maildb=session.getdatabase(servername(0), "Mail.Box")
    End If
    If Not maildb.isopen Then
        Set maildb=session.getdatabase(servername(0), "Mail3.Box")
    End If
    If Not maildb.isopen Then
        Set maildb=session.getdatabase(servername(0), "Mail4.Box")
    End If
    If Not maildb.isopen Then
        Set maildb=session.getdatabase(servername(0), "Mail5.Box")
    End If
    
    If Not Maildb.isopen Then
        Messagebox "Unable to locate Mail Router, Please try again Later", 0+64, "Error !"
        Exit Sub
    End If
    Set newdoc = New Notesdocument(maildb)
    Set doc = dc.getnthdocument(1)
    Call doc.CopyAllItems(newdoc, True)
    newdoc.recipients = doc.X_SpamOriginallyTo
    Call newdoc.Save(True, True)
'    Set uidoc = workspace.CurrentDocument
'    Call uidoc.DeleteDocument        
End Sub

RE: Delete document from agent

Mark,  I'm actually at home right now and don't have any of my Lotus stuff available.  I will look into this Monday morning and get back to you.

Leslie
landrews@metrocourt.state.nm.us

SELECT * FROM USERS WHERE CLUE > 0
No Rows Returned

RE: Delete document from agent

Hello Mark,

Leslie sent me a link to this, so I checked out your question and I believe that there is a problem. You say you wish to mark a document for deletion, yet you also say that you do not wish to delete before being sure that an event occured. The time lapse between the two events, marking for deletion and actually deleting, is apparently measured in hours ou days, not minutes. Do you leave your Notes client open for days at a time ? And what if there is a crash and you lose your deletion marks ?
It seems to me that the issue is with the document status. You clearly have a process where the document goes through several states (received, resent, discarded). The fact that these states have a duration of more than a day preclude the use of simple deletion marks, in my opinion.
I would rather mark the documents as RESENT, ou something like that, and store them in a different view. Then, when you have confirmation that reception has been correct, you can manually delete the document. Either that, or you can set an agent to go through the view and delete docs that are older than three weeks (to give a good margin). Or something in that idea.
Marking a doc for deletion is something to allow you to go over a list and select a number, with care but in a few minutes. I do not think that a deletion mark is something intended to stay on a doc for days before being taken into account.

Just my two cents

Pascal.

RE: Delete document from agent

(OP)
Pascal & Leslie

Thanks for looking at this for me. I accept what you say Pascal about marking documents as deleted not being ideal. I was just trying to cover myself so that if out of 50 mails forwarded, one failed to be delivered, I could still go back to it. This script is a work-in-progress and I wanted to prove it out first. Once the mails were marked deleted, it would have been easy to scan through the inbox and identify new mails from old. I suppose I could move them to a folder instead?. Question for reference though, is it actually possible to 'mark as deleted' from lotusscript, as that wasn't revealed in your comments?.

Thanks again for your input.

RE: Delete document from agent

Mark,

From the LotusNotes Help on DeleteDocument

DeleteDocument method  

Example
Marks the current document for deletion and closes it. The NotesUIDocument object is no longer available once you call this method.

Defined in
NotesUIDocument
Syntax
Call notesUIDocument.DeleteDocument
Usage
The document is not actually deleted from the database until the user refreshes the view or closes the database, and chooses to delete the marked document.
If the current document is already marked for deletion, this method closes the document, leaving the deletion mark in place.
Errors
This method is invalid when the document is in Edit mode: "Document command is not available."
If you try to use the NotesUIDocument object after calling this method, Notes raises an error: "NotesUIDocumentWnd is no longer valid."

Good luck!  

Leslie
landrews@metrocourt.state.nm.us

SELECT * FROM USERS WHERE CLUE > 0
No Rows Returned

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close