You can find out the name of the attachments using standard functions of Domino. Using @Functions, you can use the function @AttachmentNames, which will give you a list of attachment names for the attachments in the current document.
I have added a LotusScript example below, which will guide you in the proper direction. Using the EmbeddedObjects property of the Notes document or Rich Text item, you get a list of embedded objects in your document (i.e., attachments). Then, by using the GetAttachment method, you get a handle to an attachment, which is stored in the class type of NotesEmbeddedObject. This class has properties such as Remove, ExtractFile etc.
Dim db As NotesDatabase Dim view As NotesView Dim doc As NotesDocument Dim object As NotesEmbeddedObject Set db = New NotesDatabase ( "server", "db" ) Set view = db.GetView( "viewname" ) Set doc = view.GetLastDocument Forall o In doc.EmbeddedObjects Set object = doc.GetAttachment( o ) Call notesEmbeddedObject.ExtractFile ( "path to save file to" ) Call notesEmbeddedObject.Remove End Forall