Lotus newbie- copy problem

hello

i made a button to copy a email and it works if i put this action on the form “message” but i would like to be able to use it on the mail “inbox” Folder. this is my code:

Sub Click(Source As Button)

Dim workspace As New NotesUIWorkspace 

Dim uidoc As NotesUIDocument 

Dim sourceDoc As NotesDocument 

Dim destinationDoc As NotesDocument 

Dim sourceDatabase As New NotesDatabase("","suupport.nsf") 

Dim destinationDatabase As New NotesDatabase("","ttraiiiinee.nsf")



Set uidoc = workspace.CurrentDocument 

Set sourceDoc=uidoc.Document 

Set destinationDoc = sourceDoc.CopyToDatabase(destinationDatabase) 

    'Set newNotesDocument = notesDocument.CopyToDatabase( notesDatabase ) 

'send to inbox

Call destinationDoc.PutInFolder(“($Inbox)”)

Messagebox(“copied”)

End Sub

any suggestion ??

Subject: Try this in a folder\view action

I guess you could put it in an agent and run it from the Actions menu too

Sub Click(Source As Button)

Dim workspace As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Dim sourceDoc As NotesDocument

Dim destinationDoc As NotesDocument

Dim sourceDatabase As New NotesDatabase(“”,“suupport.nsf”)

Dim destinationDatabase As New NotesDatabase(“”,“ttraiiiinee.nsf”)

Dim session As New NotesSession

Dim db As NotesDatabase

Dim collection As NotesDocumentCollection

Set db = session.CurrentDatabase

Set collection = db.UnprocessedDocuments

Set sourcedoc = collection.GetFirstDocument()

While Not(sourcedoc Is Nothing)

Set destinationDoc = sourcedoc.CopyToDatabase(destinationDatabase)

'send to inbox

Call destinationDoc.PutInFolder(“($Inbox)”)

Messagebox("copied " & sourceDoc.Subject(0) )

Set sourcedoc = collection.GetNextDocument(sourcedoc)

Wend

End Sub

Subject: DocumentContext

Look in the Designer help for “DocumentContext property”. There are several examples there of getting the document selected in the view.