I managed to export multiple charts as pdf and download it on client side. Is there a way to email that pdf to email that user types. I was not able to find anything. I am using .net framework on server side.
Is it possible to send pdf to server using ajax and to send it to email from server that way?
Assuming that you've got the PDF content and the email address to send it to from the client side, you can send email via .NET from your back-end server. This used to be done via the built-in SmtpClient class but Microsoft now recommends people to use other options like MailKit instead.
You're also going to need an email server to connect to which will handle the delivery of those emails. This could be Gmail if you already have an account or an alternative like SendGrid
As far as getting the PDF content of the chart, Highcharts appears to be taking the SVG content of the chart and using svg2pdf to produce the PDF when not using an export server.
Since there appears to be no (documented) way of exporting to anything other than a file, you're likely going to need to mimic this process yourself by taking the SVG content via chart.getSVG() and then using svg2pdf to get your PDF content to send to your server.
Highcharts is a client html2print generator and like jsPDF or other client based solutions the PDF generation is per user selection of PDF printout options. (The client has control over PDF so no need for them to email it to self or others, unless they have to.)
Per link above
However, for situations where you may be generating a report for a client who has just seen the screen (and you don't need to change the chart in anyway) - why would you want to render the chart server side? when the client has already done the work.
To build server side automatically using a browser the server needs generally to process it, just like a user, with say chrome --headless options for html2pdf (and chrome can normally do that in one line, but with limited user layout options).
At that point you could have a PDF for attachment by any conventional mime application/pdf means (e.g. convert to base64.txt).
However due to the more dynamic drawing of svg (rather than a static insert) I could not run an Out.PDF --headless just by CLI, so it would need a driven solution such as selenium/puppeteer. THUS you may need to follow the suggestions in the lee-m above answer to build and modify the svg output.
for me I was able to run printEdge.vbs (with my current landscape defaults)
DIM shell
SET shell = WScript.CreateObject("WScript.Shell")
Shell.Run "cmd /c start msedge.exe file:///C:/Users/WDAGUtilityAccount/Documents/highchart.htm"
WScript.Sleep(4000)
Shell.SendKeys "^p"
WScript.Sleep(3000)
Shell.SendKeys "{enter}"
WScript.Sleep(1000)
Shell.SendKeys "{enter}"
WScript.Sleep(1000)
Shell.SendKeys "y"
WScript.Sleep(1000)
Shell.SendKeys "{esc}"
WScript.Sleep(1000)
Shell.SendKeys "%{f4}"
Related
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 have a WinForms application where a user can configure email templates that will later get mail merged with client data from the database and then sent via SMTP.
I have everything working fine, but the issue comes when the user saves images inside the template body. I'm using a DevExpress RichEdit control to allow the users to create this email body, and that control converts it to HTML that I use to send. When images are there, it uses data-uri to embed the image directly into the HTML.
The problem now comes when I send the email in this way using data-uri images, not all clients render it properly. I just tested it in Outlook, and it doesn't seem to work. I know some web based email clients will work, but I need this to work all the time, at least for the widely used email clients.
I'm wondering if others have solved this problem and what might be the best solution here? I suppose I could send the images as attachments and then reference the attachment, although I'm not sure if this is a best practice. The other alternative though is to host each image on a server somewhere, then create a service which would have to store the images (like in a DB), and provide a way to query this image over the web using an ID. Then my emails would use an img src=site/getImg?imgID=xxx type thing. However, this seems like a lot of work to do what I want to accomplish and I'm hoping I could avoid it with something easier.
Thanks in advance for any advice!!
Adding images as attachments will work, but has the downside of a larger payload and higher bandwidth utilization both for you and for your recipients. The code for adding attachments in .net is pretty simple:
var message = new MailMessage();
foreach (string path in attachmentPaths)
{
if (File.Exists(path))
{
message.Attachments.Add(new Attachment(path));
}
}
On the other hand, referencing images stored on the web somewhere reduces the size of your emails and also opens up the possibility of gathering tracking data on clients that request images. Of course, most email clients will first ask the user whether they want to download images, so your tracking will only be rough.
you should be try save the images in the local disk , and the next include the who Embedded images.
// Add image attachment from local disk
Attachment oAttachment = oMail.AddAttachment( "d:\\test.gif" );
// Specifies the attachment as an embedded image
// contentid can be any string.
string contentID = "test001#host";
oAttachment.ContentID = contentID;
oMail.HtmlBody = "<html><body>this is a <img src=\"cid:"
+ contentID + "\"> embedded image.</body></html>";
Sorry for not explain, I speak only a little in english
I´m sending the value of a variable via POST to a PHP page in C#. I get the data stream from the server that has all the web page in HTML with the value of the POST. This information is stored in a string variable.
I would like to open a browser and show the web page (maybe using System.Diagnostics.Process.Start("URL")), without having to save it in a file, this is showing the page in the moment and, when the browser is closed, no file is stored in the server.
Any idea?
Drop a WebBrowser control into a new form webBrowser1 and set its DocumentTextProperty to your result html
webBrowser1.DocumentText = ("<html><body>hello world</body></html>");
source:
<html><body>hello world</body></html>
You aren't going to be able to do that in an agnostic way.
If you simply wanted to open the URL in a browser, then using the Process class would work.
Unfortunately, in your case, you already have the content from creating the POST to the server, and you really want to stream that response in your application to the browser.
It's possible among the some browsers, but it's not able to be done in an agnostic way (and it's complicated even when targeting a specific browser).
To complicate matters, you want the browser to believe that the stream you are sending it is really coming from the server, when in reality, it's not.
I believe that your best bet would be to save the response to the file system in a temp file. However, before you do, add the <base> tag to the file with the URL that the file came from. This way, relative URLs will resolve correctly when rendered in the browser.
Then, just open the temporary file in the browser using the Process class.
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.
I'm using SubVersion and TRAC on a C# project I am working on, and I have my TRAC system setup with a email address that can be used to create tickets. In my program I've added a simple "FeedBack" button in my program which sends an email to this address. To open the email I'm just "starting" a mailto link as shown below.
System.Reflection.Assembly assem = System.Reflection.Assembly.GetExecutingAssembly();
string ver = assem.GetName().Version.ToString();
System.Diagnostics.Process.Start("mailto:foo#bar.com?subject=<Provide a title for your feedback here>&body=< Describe the problem you are having or enhancement you would like to suggest here. Please be as descriptive as you can, and if possible list out the actions that will replicate the problem >%0D%0A%0D%0A%0D%0AVersion: "+ver);
The problem I'm running into is if the user is using Outlook and their copy of Outlook is setup to HTML the ticket that gets created ends up having a bunch of HTML code that I have to clean up. Is there some way to notify whatever mail client is handling it to send the email as text rather then HTML?
There's nothing you can do (besides education) on the client - there's nothing in mailto to control a client side program. And, frankly, with the proliferation of web-based email - I think mailto is showing it's age.
Outlook should send a mime/multipart message, with both plain text and HTML parts. I'd guess you could extend or patch Trac to only grab the text/plain portion.
Otherwise, just create a form in your app to capture the email info. Again, if someone is using Hotmail or GMail - mailto is not likely to work anyway (or will open up their unconfigured Outlook Express, where they will dutifully type up an email and press Send. Only it won't go anywhere, because no SMTP servers are configured - so it will languish in the Outbox for years. Not that they will notice though...).