Sub Initialize
Dim session As New notessession
Dim db As notesdatabase
Set db = session.currentdatabase
Dim doc As notesdocument
Set doc = session.DocumentContext
'Get parentID from address variable
Dim qstring As Variant
qstring = Evaluate("@Rightback( Query_String ; 15)", doc)
Dim ParentID As String
ParentID = qstring(0)
'Get a handle on the parent document
Dim pdoc As NotesDocument
Set pdoc = db.GetDocumentByUNID( ParentID )
Dim URL As String
URL = "/gdc/datacollect.nsf/files/" & pdoc.UniversalID & "/$File/" & pdoc.dr_attachmentname(0) & "?OpenElement"
'Force the browser to download and pass the file URL
Print "Content-Type:application/download"
Print "Content-Disposition:attachment; filename=" & Chr(34) & pdoc.dr_attachmentname(0) & Chr(34)
Print "[" + URL + "]"
End Sub