473,795 Members | 2,766 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Conten tType = "applicatio n/octet-stream; name=Test.eml"
Response.AddHea der("content-transfer-encoding", "binary")
Response.AddHea der("content-disposition", "attachment;fil ename=Test.eml" )
Response.Conten tEncoding = System.Text.Enc oding.GetEncodi ng(1251)
Response.Binary Write(bytes)
s.Close()
s = Nothing

Anyone got any ideas?

Stu

Nov 19 '05 #1
4 3033
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.Charse t = "" 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******** ******@TK2MSFTN GP09.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.Conten tType = "applicatio n/octet-stream; name=Test.eml"
Response.AddHea der("content-transfer-encoding", "binary")
Response.AddHea der("content-disposition", "attachment;fil ename=Test.eml" )
Response.Conten tEncoding = System.Text.Enc oding.GetEncodi ng(1251)
Response.Binary Write(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******** ******@TK2MSFTN GP09.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.Conten tType = "applicatio n/octet-stream; name=Test.eml"
Response.AddHea der("content-transfer-encoding", "binary")
Response.AddHea der("content-disposition", "attachment;fil ename=Test.eml" )
Response.Conten tEncoding = System.Text.Enc oding.GetEncodi ng(1251)
Response.Binary Write(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******** *******@tk2msft ngp13.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******** ******@TK2MSFTN GP09.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.Conten tType = "applicatio n/octet-stream; name=Test.eml"
Response.AddHea der("content-transfer-encoding", "binary")
Response.AddHea der("content-disposition", "attachment;fil ename=Test.eml" )
Response.Conten tEncoding = System.Text.Enc oding.GetEncodi ng(1251)
Response.Binary Write(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.Charse t = ""
Response.Conten tType = "applicatio n/octet-stream; name=Re_
Test message.eml"
Response.AddHea der("content-transfer-encoding", "binary")
Response.AddHea der("content-disposition",
"attachment;fil ename=Re_ Test message.eml")
Response.Conten tEncoding =
System.Text.Enc oding.GetEncodi ng(1251)
Response.Binary Write(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
1879
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 command to a Microsoft Access database. The database returns either the record that was selected or a "no record" message. The db_read.asp file relays this information to Authorware. If a record was returned, Authorware displays it. If there...
5
3039
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 advance! : )
4
3692
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 Web.HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=" & FileName) .Charset = ""
1
5401
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 completely/succsessfully on the client's computer before updating some metadata on the server (file downloaded date for instance) However, All examples i have tried, and all examples I have found that other people says works - doesn't work for me :-(
1
4359
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 part, but I couldn't initially work out how to manipulate the page setup to change page margins and orientation, that's why I was looking at Microsoft.Office.Interop. But with Microsoft.Office.Interop I couldn't fiure out how to stream HTML...
4
2477
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 the xml is fully loaded. The link to the xml file is valid. my code is as follows... xmlf = "http://www.tcc-net.com/associates/xml/coursesopen.php?fieldSet=schedule&order=code" stylef = "page1.xsl" set xmlDoc =...
7
10499
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 corrupted. The had not been a problem before but it seems to have been introduced when I refactored the writing to the response to a buffered version to prevent potential OutOfMemoryExceptions (you wouldn't believe the size of some of these...
7
2959
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 have file access anywhere on the remote server, and therefore I can't figure out how I can create a file. Is it possible to utilize StreamWriter to create a new file and somehow display it for the user to save, without actually saving the file...
4
6916
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 function creates the file as expected. When I loop through my array I get the error - "ArgumentException was unhandled - Illegal characters in path" The value "C:\Temp.txt" is the first value in the array - as it works
0
9519
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10213
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10000
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9040
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6780
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5436
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.