0

I have this variable like so:

var htmlBody = "<table border = '1' cellspacing='0' align = 'center'><tr><th>Job #</th><th>Task</th><th>Date</th></tr></table>”;

What I tried to do is create a mailto link so the email client opens with To empty, the subject Schedule and the body as htmlBody

window.location = "mailto:?subject=Schedule&body=" + htmlBody;

However you cannot have html code in a mailto link, so is there an alternative to what I am trying accomplish? I don't want to send the email, I just want the client to open with Subject and htmlBody.

Or is there away to accomplish what I am trying to do with ASP.NET MVC? I open to either jquery or .NET

user979331
  • 11,039
  • 73
  • 223
  • 418

1 Answers1

1

To open an email programmatically you can use window.location.assign with a mailto: link:

window.location.assign('mailto:test@test.com');

Pass your parameters as query string like you did:

window.location.assign('mailto:test@test.com?subject=test&body=testBody');

Passing HTML to the body is not possible as seen here: MailTo with HTML body

G43beli
  • 3,835
  • 4
  • 21
  • 28