Sub Initialize
Dim session As New notessession
Dim db As notesdatabase
Set db = session.currentdatabase
Dim doc As notesdocument
Set doc = session.DocumentContext
'Get parent document and attachment
Dim pdoc As NotesDocument
Set pdoc = db.GetDocumentByUNID( doc.ParentDocumentUNID )
Dim URL As String
URL = "/" & doc.dbURL(0) & "/files/" & doc.ur_compname(0) & "~" & doc.ur_title(0) & "/$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) & Cstr(pdoc.dr_attachmentname(0)) & Chr(34)
Print "[" + URL + "]"
'********************************************************************
End Sub