473,385 Members | 1,764 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,385 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 3014
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.