Force the open/save dialog box when download files on the web.

Normally, files such as PDF's and XLS will open directly in the browser without prompting the user. The agent below will force the browser to provide the open/save dialog box when downloading files from the web.
LotusScript


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

Images/Screenshots:

Posted by fbrefere001 on Monday February 24, 2003