I currentlyu have an ASP page that generates an .mht file that the user can
save, using the following code:

Response.AddHeader "Content-Disposition", "attachment; filename=" & filename

Is there any way that, instead of the user being able to save the file, the
file will be saved to the server whenever the page is requested? This way I
can save the file to a known path on the server and add it as an attachment
to be emailed out.

Any help will be greatly appreciated.
Thanks,

Carolyn

RE: can you save asp generated .mht file to server? by CarolynSpeakman

CarolynSpeakman
Wed Jun 01 04:32:21 CDT 2005

If anyone is interested, I used some code found on another thread to get what
I wanted. Putting this in a sub which is called from a loop creates documents
for each client (saving the .mht files as .doc so that they can be emailed)

Sub genDoc(clientID)
Dim objSXH, objADOStream

Set objSXH = Server.CreateObject("Msxml2.ServerXMLHTTP.4.0")
objSXH.setTimeouts 0,0,0,0 'They're big files I'm generating
link = "http://mydomain/myPage.asp?clientID=" & Trim(clientID)
objSXH.open "GET", link, false
objSXH.send


Set objADOStream = Server.CreateObject("ADODB.Stream")
objADOStream.Type = 1 'Binary
objADOStream.Open
objADOStream.Write objSXH.responseBody
strFileName = "C:\docs\" & clientID & ".doc"

objADOStream.SaveToFile strFileName
objADOStream.Close
End Sub

"Carolyn Speakman" wrote:

> I currentlyu have an ASP page that generates an .mht file that the user can
> save, using the following code:
>
> Response.AddHeader "Content-Disposition", "attachment; filename=" & filename
>
> Is there any way that, instead of the user being able to save the file, the
> file will be saved to the server whenever the page is requested? This way I
> can save the file to a known path on the server and add it as an attachment
> to be emailed out.
>
> Any help will be greatly appreciated.
> Thanks,
>
> Carolyn