0

I wrote java script code to open mail client at the same time i am pre populating to,cc,subject and body.But here problem is as part of body i need some html styles.I write like as follows

<html>
<body>
<input id="sendemail" type="submit" value="Submit">
</body>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script>
$("#sendemail").click(function() {
        alert("Hai");
        try {

            var email='prospectpartner@gmail.com';
            window.location="mailto:"+email+"?subject=Subject&**body**="+<html>Please attach your invitation letter to this email<b><i>Primary Contact</i></b><br/>First name:</html>;
         }
        catch(err){
            alert(err);
        }
        });
</script>
</html>

if you observe the body element value i am giving html elements as part of body.Please see the attached image which is body of outlook.Those html elements are not converting.Please see the below image of outlook enter image description here

user3663712
  • 121
  • 1
  • 3
  • 8

2 Answers2

1

If you are using javax.mail then you must set the content of the message to text/html;

message.setContent(body, "text/html");

The body of the message can then be thought of as the <body> tag in HTML

However, you cannot execute Javascript in an email.

glend
  • 1,592
  • 1
  • 17
  • 36
0

The body section is a plain text, not html markup.

Take a look at the The mailto URL scheme which states the following:

The special hname "body" indicates that the associated hvalue is the body of the message. The "body" hname should contain the content for the first text/plain body part of the message. The mailto URL is primarily intended for generation of short text messages that are actually the content of automatic processing (such as "subscribe" messages for mailing lists), not general MIME bodies.

Community
  • 1
  • 1
Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
  • so it is not possible to give html code as part of outlook mail body.Is there any other workaround for my requirement.If possible can you suggest me. – user3663712 Apr 21 '15 at 14:35
  • See [How to send an email from JavaScript](http://stackoverflow.com/questions/7381150/how-to-send-an-email-from-javascript). – Eugene Astafiev Apr 21 '15 at 15:20