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.
Related
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.
I have an application which allows sending Emails to different clients. I have used free text editor to write the draft and send the email.
All works fine but when I send the email with free text box content as message body sometimes the body is displayed as html code itself and not as plain text. This happens once in a while whereas most of the time message body is displayed as plain text.
But the risk is sometimes my clients might receive the Email body as html code instead of plain text which is bad.
Why this happens and how to avoid such risk??
I am currently using a string to embed a base64 image in email via EWS but the embeded images is not showing up in my outlook client when i receive the email.
If i save the email source it is viewable in my browser.
static string str = #"<head><meta http-equiv=""Content-Type"" content=""text/html; charset=utf-8"" /></head><body><img src=""data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="" /></body></html>";
Is it possible to embed images into a HTML email message in this method?
Best Regards
Chris
Data URI scheme may be not supported by the receiving party:
What is Data URI support like in major email client software?
Consider using MIME related (cid protocol) to send html email with embedded images. I believe it is far better supported. I'm not sure if it can be easily done with SmtpMail.
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...).