I'm trying to send a message in rtf format but on reception it is not interpreted correctly by gmail, etc. (except Mail.app on MacOS). Here is a sample code. Some client application consider it as "text".
String body = #"{\rtf1\ansi\deff0{\colortbl;\red0\green0\blue0;\red255\green0\blue0;} This line is the default color\line \cf2 This line is red\line \cf1 This line is the default color}"
message.Body = new TextPart("rtf") { Text = body };
Where am I wrong?
As jdweng points out, most mail clients do not support RTF.
Google mail only supports HTML and plain-text messages as far as I know.
I tried testing this by using Outlook to send an RTF message to GMail, but alas, my Exchange server always overrides the RTF by converting it to HTML and so GMail always receives text/html instead of text/rtf.
I might be able to get Outlook to send text/rtf if I configure it to send via some non-Exchange account, but I'm too lazy to bother.
Related
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}"
I have a user input on a web page.
They are able to type a message and send.
The message gets sent to them via SMTP and the client they'll be using is outlook.
The problem I am getting is that emoji [😂🐱👓🤷♂️👍] are coming through as varying amount of ?? question marks.
There's also a number of problematic characters that come through when they paste content from work like special quotes and the em dash which is often substituted in word when people type a dash.
I know outlook supports emoji as I can type them in with Windows + ; and send them fine. But this is getting mangled somehow when I send it through the SMTP client.
Debugging is showing the emoji correctly before sending it through the SMTP client.
Any ideas what I need to do to get it to send without resorting to stripping these characters out? I'd like for people to be able to use these emoji if they like.
Thanks to #Steve for making me reconsider the obvious 🙌
Turns out all I needed to do was set the BodyEncoding to System.Text.Encoding.UTF8 on the message.
Setting the IsBodyHtml property to true was not enough.
Not sure what the default is for this to not work without setting it to UTF8 but oh well.
mail.BodyEncoding = System.Text.Encoding.UTF8;
https://learn.microsoft.com/en-us/dotnet/api/system.net.mail.mailmessage.bodyencoding
Is there a way I can use mailto: or JavaScript to send a string containing HTML code to the body of an email message so that the HTML will render? This just renders as text and doesn't actually display an image (same for a mailto: link):
window.open('email#email.com&Subject=Test&Body=<img src="MyImageURL" />');
In the real code, I'm using the full URL of the image, with the http://www..., and also, I confirmed that the email type is HTML and not plain text.
This is a project requirement, to allow someone to send a formatted message through their own email rather than us sending it server-side on their behalf through our SMTP server.
no, there is no way to do this using javascript or mailto. if you wanna read all features to mailto protocol please check this page.
I'm trying to send an html email to a gmail account, but for some reason, Google is stripping away the html from my email. The Html is preserved when I send to other accounts (non-gmail accounts) so I know that my html is correct.
Here's how I'm going about it:
I have an aspx page, that I use as an email template.
I grab the html from the aspx page from within a web service (done in C#)
Dynamically fill in the non-static content through c# code within the web service.
Send that as the email body.
Does anyone happen to know why gmail is removing the html?
Thanks in advance.
You need to be sure to set the IsBodyHtml property to true on your MailMessage:
var message = new MailMessage();
message.IsBodyHtml = true;
// Fill and send message here
Check out the MSDN reference for more info:
System.Net.Mail.MailMessage Members
The Html is preserved when I send to other accounts (non-gmail accounts) so I know that my html is correct.
It's not a programming issue. If it were, as you've observed, this would happen to all clients.
The issue is this: Most modern email clients allow users to choose to disallow html messages, or always view them as plain text. That could be what is happening here. You have to code to expect this, because you can't control user's preferences. If they have this enabled, and you send it as html only, it will look ugly to them.
However, for a solution to your issue, you should always be sending your mail as a Multi-Part Mime message to allow all clients to get a nice readable version.
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...).