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.
Thanks in advance.
RE: Delete document from agent
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
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
Leslie
landrews@metrocourt.state.nm.us
SELECT * FROM USERS WHERE CLUE > 0
No Rows Returned
RE: Delete document from agent
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
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
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