I have a csv file as an attachment to the inbox.
They should be able to view the attachment when they click on the link, but how do I display them the csv attachments??! the browser just parses it and displays the content instead of poping the open/save window.
anyone had to open a csv file as an attachment on web before? thanks.
Response.AddHeader "content-disposition","attachment; filename=myfile.csv"
Adding this header to your response will cause the browser to treat the content as an attachment and display the 'File Download' dialog instead of attempting to display the content in the web page.
Related
I need to incorporate a pdf file inside a string that will be the body of my email, because the structure of my email does not contain attachments.
Can anyone give me any ideas?
I would like to know if it is possible to open and reply as a response message on top of a saved .eml file using C#?
If yes, are there any guides that I can follow?
I am able to do so with EWS EmailMessage where the message resides in Inbox. However, due to requirements, I am required to retrieve and reply from a saved .eml file instead of replying from the email in Inbox directly.
Thank you.
No you can't do this using the EWS reply operations because EWS is a Server side API while using the EWS Managed API you using Client side library that just instrumenting the SOAP call to the backend whenever an action is taken. You can temporary import the EML back in the server https://learn.microsoft.com/en-us/exchange/client-developer/exchange-web-services/how-to-import-items-by-using-ews-in-exchange and then you reply and then delete the Message again if don't want it to exist. If your want to send using EWS you didn't want to import the message use something like mimekit to generate the MIME of the response message offline http://www.mimekit.net/docs/html/Frequently-Asked-Questions.htm then you can just sent the Mime generated by mimekit via EWS.
In theory you could achieve this, by first opening the EML file (please see this question and answer):
Retrieve Email Information from .EML Files
And then when you have the contents of the message in code, copy the data over to whatever email-sending API you are using.
Step 1:-
Click the message options menu in the top right corner of the message. Select Save email.
Step 2:-
Save the file. The file name will default to the subject line of the email, with special characters removed. Your download options depend on whether you're using Front on the web or in the desktop app:
*Web: Your file automatically saves to wherever you have it set up in your browser settings (like your Downloads folder)
*Desktop app: You will get the “Save As” prompt where you can rename the file and choose your download location
Step 3:-
You will see your .eml file in your chosen location. You can attach it to a message via drag-and-drop or with the attachment file picker.
I've got a link on my page allowing the user to listen to a captcha code, clicking the link will show a open/save dialog. If possible, I'd like the browser to just play the file, instead of requiring user interaction.
This is how I return the audio to the browser:
byte[] filebytes = Helper.TextToAudioBytes(code);
Response.AddHeader("Content-Disposition", "attachment; filename=sound.wav");
return File(filebytes, "audio/wav");
You are sending the Content-Disposition header with value attachment. This tells the browser that the file should be saved and not handled as normal content. Removing this will allow the browser to handle the file in a manner based on the browser settings.
Note that the browser settings might still be "save the file" or whatever the user has decided, not necessarily "play the sound".
I have some e-mails that i would like to store in SQL Server database and render within an asp.net web application.
Currently the .msg files are stored in a BLOB field and and a link to download the file to user's system is given.
However, I want to render the content of the message directly without giving the user any options to download it. The messages are in HTML format with embedded images.
All suggestions are welcome.
You need parse MIME. You can find classes for it on the next page: http://www.codeproject.com/KB/IP/ReceivingMail.aspx
You can load mail body to the MailItem:
Pop3Lib.MailItem m = new Pop3Lib.MailItem("mail body here");
Pop3Lib.MailItem m = new Pop3Lib.MailItem(System.IO.File.ReadAllText("C:\\mymail.msg"));
Response.Write(m.GetText());
Hii,
My requirment is to show a dynamically created pdf file directly to my web page. It works fine for the system which is having pdf reader software. But for the system which does not have the pdf software it is showing error like below
The XML page cannot be displayed
Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.
An invalid character was found in text content. Error processing resource 'http://localhost:4252/OmanePost/Customer/EBox/PD...
I need to handle this situation bit differently.i.e In this situation the file should be save to the physical location of the system for that i need to identify whether the client machine has pdf software or not then i can manage properly
I m using ASP.NET 2.0 version
It looks to me that you are serving your PDF with an XML mime/content-type. Make sure you set your content-type to application/pdf and you'll probably get a more suitable browser response.
In this case the browser should ask the user to open the file in an external application.
Please verify that you are sending the correct Content-Type: application/pdf header. Certain versions of Microsoft's browser ignore the content-type header, so you need to specify a filename ending in .pdf in the content disposition header: Content-Disposition: inline; filename=filename.pdf;
Note: I have not verified that it works with "inline" instead of "attachment", but I think it is worth a try.
My requirment is to show a dynamically created pdf file directly to my web page.
Try online ZohoViewer that takes a PDF file link and displays in the browser without requiring PDF reader on the client machine. As such there's no way to check if the client machine has a pdf reader or not.
You can not identify that client system has pdf software using javascript, asp.net, c#.
If the PDF reader software is not there and the PDF is a valid PDF then it should not throw exception. Instead it asks for a software in client machine which can read the file.