I have the below code :
Dim filePath As String = Request.QueryString("FilePath")
Dim fileName As String = filePath.Substring(filePath.LastIndexOf("/") + 1)
Dim ext As String = Path.GetExtension(fileName)
'If (ext = ".xls") Then
' Response.ContentType = "application/vnd.ms-excel"
'ElseIf (ext = ".xlsx") Then
' Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
'End If
If ext = ".msg" Then
Response.ContentType = "application/octet-stream"
'Response.ContentType = "application/vnd.ms-outlook"
ElseIf (ext = ".xls") Then
Response.ContentType = "application/vnd.ms-excel"
ElseIf (ext = ".xlsx") Then
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
End If
'fileName = Server.MapPath("~\\files\\RAP_Batch_Upload_form.xls")
Response.AppendHeader("Content-Disposition", "attachment;filename=" & fileName)
'Response.AddHeader("Content-Length", New System.IO.FileInfo(fileName).Length)
'Response.AddHeader("Content-Length", New System.IO.FileInfo("Batch_test_11.xlsx").Length)
Response.Redirect(filePath)
Response.End()
I am able to download the files with .xls and .xlsx files but .msg files will give page not found error. The files are stored in an Attachments folder and a sample filePath looks like http://our.domain.com/Attachment/2017123456 Demo_Re.msg (Space is part of the fileName and for .xls and .xlsx files that is not a problem).
Could anybody tell me what am I missing.