0

I'm working on ASP.net mvc5 project, and i need to display outlook when clicking on button in the view, content of email should be int html.

I've tried using mailto, but it doesnt not support html content, i need to know if there is another way to do that

Thanks

  • Does this answer help? http://stackoverflow.com/questions/5620324/mailto-with-html-body ... it's not possible to add HTML. You can add linebreaks though as evidenced in one of the answers. – Steven Lemmens Jul 07 '15 at 14:48
  • I need to display html tables and styles – xquizzes xquizzes Jul 07 '15 at 14:50
  • Then you cannot do this with a mailto:link. The best you can do then, I suppose, is construct the e-mail yourself using code and sending it through asp.net itself, instead of using something like outlook. – Steven Lemmens Jul 07 '15 at 14:52
  • I need to display first so as to check it's content is right, then click send button on outlook, by the way sending email via asp.net without outlook works well. – xquizzes xquizzes Jul 07 '15 at 14:54
  • Yes, you'll have to think of a way of displaying the email in the browser then. Perhaps you can use ASP.NET to load in an HTML template of your e-mail, set some fields to the right text (with String.Replace for example) and then allow the user to click the send button (still in the browser). – Steven Lemmens Jul 07 '15 at 14:56
  • I see, okey i will try that, thanks for helping – xquizzes xquizzes Jul 07 '15 at 14:57
  • No problem. I will convert these comments into one helpful answer for anyone who might happen upon this page in the future. If you have any other difficulties you encounter, don't be shy to open up a new question. – Steven Lemmens Jul 07 '15 at 15:02
  • I really appereciate :) – xquizzes xquizzes Jul 07 '15 at 15:05
  • Done. If you don't mind, please accept my answer as the accepted answer. Then I'll remove my comments as well, so in the future it'll look like a clean post :-) – Steven Lemmens Jul 07 '15 at 15:08
  • Guys im looking into the same answer, can anyone help – Chandu Nov 27 '20 at 17:08

1 Answers1

0

Well, if you just want to add some line breaks, that is possible, as evidenced in this answer:

MailTo with HTML body

Relevant part:

If you are able to use javascript then "encodeURIComponent()" might be of use like below...

var formattedBody = "FirstLine \n Second Line \n Third Line";
var mailToLink = "mailto:x@y.com?body=" +
encodeURIComponent(formattedBody);
window.location.href = mailToLink;

Otherwise, if you want a solution with the full monty (images, tables, ...) in y our e-mail, then you're out of luck with a simple "mailto" link.

Then you'll have to think of a way to construct the e-mail via ASP.NET and send it using the System.Net.Mail namespace. Perhaps you can use ASP.NET to load in an HTML template of your e-mail, set some fields to the right text (with String.Replace for example) and then allow the user to click the send button (still in the browser) or send it automatically if there is no user action required.

Community
  • 1
  • 1
Steven Lemmens
  • 620
  • 5
  • 18