473,386 Members | 1,962 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Directing a file to the output response...

Stu
Hi,

I need to push a .eml file (MS email pickup format) to the browser when the
user clicks on a button. The file is outside of the web space so I used this
method (which worked with word docs). This nearly works....but the email
file has the web page contents tagged on the end of it. It looks like the
Response.Clear() is not working.

'load file in to byte array
Dim s As New FileStream("c:\Test.eml", FileMode.Open)
Dim bytes() As Byte
ReDim bytes(s.Length)
s.Read(bytes, 0, s.Length)

'output file to the browser
Response.Clear()
Response.ContentType = "application/octet-stream; name=Test.eml"
Response.AddHeader("content-transfer-encoding", "binary")
Response.AddHeader("content-disposition", "attachment;filename=Test.eml")
Response.ContentEncoding = System.Text.Encoding.GetEncoding(1251)
Response.BinaryWrite(bytes)
s.Close()
s = Nothing

Anyone got any ideas?

Stu

Nov 19 '05 #1
4 3015
Stu,

I don't know if this will work or not, but I was just taking a look at some
code I wrote to output a datagrid as an excel spreadsheet and I'm using
Response.Charset = "" before the output.

Try it out, maybe that's what's left over?

I've got my fingers crossed.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Stu" <s.****@cergis.com> wrote in message
news:uV**************@TK2MSFTNGP09.phx.gbl...
Hi,

I need to push a .eml file (MS email pickup format) to the browser when
the user clicks on a button. The file is outside of the web space so I
used this method (which worked with word docs). This nearly works....but
the email file has the web page contents tagged on the end of it. It looks
like the Response.Clear() is not working.

'load file in to byte array
Dim s As New FileStream("c:\Test.eml", FileMode.Open)
Dim bytes() As Byte
ReDim bytes(s.Length)
s.Read(bytes, 0, s.Length)

'output file to the browser
Response.Clear()
Response.ContentType = "application/octet-stream; name=Test.eml"
Response.AddHeader("content-transfer-encoding", "binary")
Response.AddHeader("content-disposition", "attachment;filename=Test.eml")
Response.ContentEncoding = System.Text.Encoding.GetEncoding(1251)
Response.BinaryWrite(bytes)
s.Close()
s = Nothing

Anyone got any ideas?

Stu

Nov 19 '05 #2
You need to call Response.End() to stop the rest of the request from
happening.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!

"Stu" <s.****@cergis.com> wrote in message
news:uV**************@TK2MSFTNGP09.phx.gbl...
Hi,

I need to push a .eml file (MS email pickup format) to the browser when
the user clicks on a button. The file is outside of the web space so I
used this method (which worked with word docs). This nearly works....but
the email file has the web page contents tagged on the end of it. It looks
like the Response.Clear() is not working.

'load file in to byte array
Dim s As New FileStream("c:\Test.eml", FileMode.Open)
Dim bytes() As Byte
ReDim bytes(s.Length)
s.Read(bytes, 0, s.Length)

'output file to the browser
Response.Clear()
Response.ContentType = "application/octet-stream; name=Test.eml"
Response.AddHeader("content-transfer-encoding", "binary")
Response.AddHeader("content-disposition", "attachment;filename=Test.eml")
Response.ContentEncoding = System.Text.Encoding.GetEncoding(1251)
Response.BinaryWrite(bytes)
s.Close()
s = Nothing

Anyone got any ideas?

Stu

Nov 19 '05 #3
Stu
Many thanks - and so simple as well :-)


"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:%2***************@tk2msftngp13.phx.gbl...
You need to call Response.End() to stop the rest of the request from
happening.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!

"Stu" <s.****@cergis.com> wrote in message
news:uV**************@TK2MSFTNGP09.phx.gbl...
Hi,

I need to push a .eml file (MS email pickup format) to the browser when
the user clicks on a button. The file is outside of the web space so I
used this method (which worked with word docs). This nearly works....but
the email file has the web page contents tagged on the end of it. It
looks like the Response.Clear() is not working.

'load file in to byte array
Dim s As New FileStream("c:\Test.eml", FileMode.Open)
Dim bytes() As Byte
ReDim bytes(s.Length)
s.Read(bytes, 0, s.Length)

'output file to the browser
Response.Clear()
Response.ContentType = "application/octet-stream; name=Test.eml"
Response.AddHeader("content-transfer-encoding", "binary")
Response.AddHeader("content-disposition", "attachment;filename=Test.eml")
Response.ContentEncoding = System.Text.Encoding.GetEncoding(1251)
Response.BinaryWrite(bytes)
s.Close()
s = Nothing

Anyone got any ideas?

Stu


Nov 19 '05 #4

I tried this. I created a webform1.aspx and added the iframe and called
the webform2.aspx in that iframe.
webform2.aspx had the below code:
Try
Dim s As New FileStream("d:\Test\Re_ Test message.eml",
FileMode.Open)
Dim bytes() As Byte
ReDim bytes(s.Length)
s.Read(bytes, 0, s.Length)

'output file to the browser
Response.Clear()
Response.Charset = ""
Response.ContentType = "application/octet-stream; name=Re_
Test message.eml"
Response.AddHeader("content-transfer-encoding", "binary")
Response.AddHeader("content-disposition",
"attachment;filename=Re_ Test message.eml")
Response.ContentEncoding =
System.Text.Encoding.GetEncoding(1251)
Response.BinaryWrite(bytes)
s.Close()
s = Nothing
Response.End()
Catch ex As Exception
Response.Write(ex.Message)
End Try

But it is still opeing the .eml/.msg file in a different window and not
within the iframe . This is not required.
Any suggestions.

I have to open the .msg / .eml files in the browser just as .doc files
are opened in the native applications within the browser.
Please inform how this can be done.

Alternatively using asp.net 1.1 and vb.net/c# can I open the .msg/.eml
files in native application within any placeholder / literal

or any client side scripting

All ideas are welcome.

Thanks in advance
Atul

--
ai4u
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------

Apr 27 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: James_101 | last post by:
My training piece is in Authorware. The user logs in with last name and a four-digit number. Authorware sends this user identifier to an asp page called db_read.asp. This file sends a SQL SELECT...
5
by: Peteroid | last post by:
I'm doing a managed C++ application. Is there a way to re-direct 'cout' to output destinations other than the 'black console' that comes up? Specifically, re-direction to a text file? Thanks in...
4
by: Dorte | last post by:
Hi, I am using the code below to stream a CSV file with the response object. Dim FileName As String = "Test.csv" With Web.HttpContext.Current.Response ...
1
by: Roy | last post by:
Hi, I have a problem that I have been working with for a while. I need to be able from server side (asp.net) to detect that the file i'm streaming down to the client is saved...
1
by: Andrew | last post by:
I'm adding this as it to me a while to figure out all the pieces to be able to do this without using Microsoft.Office.Interop which caused me problems on the web-server. Streaming is the easy...
4
by: Brian Quigley | last post by:
Hi, i am trying to write a script to parse an external xml file, but am having problems... the problem i think has to do with me trying to do Response.Write(xmlDoc.transformNode(xslDoc)) before...
7
by: eventuranza | last post by:
For my application, there users can upload and download files to the a webserver. Straightforward enough. However, when they upload a PDF file then try to download it, the file seems to be...
7
by: =?Utf-8?B?TWlrZQ==?= | last post by:
Hi. I'm building an ASP.NET site which is hosted on a remote server. When I try to create a new file using StreamWriter I must specify the drive location where the file will be saved. I don't...
4
by: Vlad | last post by:
I am having problems using the file.create method within a function that is called when looping through an array of filepaths. If I call my function with a hardcoded file path --C:\Temp.txt the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.