3

There's something I want to do that I'm 90% sure is impossible, but I just want to check on the off-chance that it's possible and someone knows how to do it.

I want to have a link on my website that, when clicked, opens the user's mail program (or GMail), composes a new message, leaves the to field empty, populates the subject field with a subject that I give (up to here I know it's possible with a mailto:) and, here's the kicker, populates the message content with an HTML message that I supply.

I know it's possible to populate using a text message, but can I do HTML too?

Ram Rachum
  • 84,019
  • 84
  • 236
  • 374
  • possible duplicate of [MailTo with HTML body](http://stackoverflow.com/questions/5620324/mailto-with-html-body) – Andrew Jul 19 '14 at 07:26
  • @Lemony-Andrew Consider that I'm not restricting the answer to `mailto:`, if someone would come up with a creative idea, I'm open to hear that. – Ram Rachum Jul 19 '14 at 07:40
  • Okay, sorry for the misunderstanding. I don't think there's a possible workaround `mailto` that does the same thing. If there isn't any way to do what `mailto` does then I know for sure, from multiple sources, it is impossible. – Andrew Jul 19 '14 at 13:34

1 Answers1

0

You can use the following piece of code if you particularly need to avoid mailto option.

var message = 'You can supply any value to this variable';

var outlookApp = new ActiveXObject("Outlook.Application");

var nameSpace = outlookApp.getNameSpace("MAPI");

mailFolder = nameSpace.getDefaultFolder(6);

mailItem = mailFolder.Items.add('IPM.Note.FormA');

mailItem.Subject = "Subject of the mail";
mailItem.To = sendto;
mailItem.HTMLBody = String(message);
mailItem.display(0);

Only limitation is that you need to have Outlook installed in the users' computer.

But I am sure you can achieve the same functionality using mailto: as well. You have to use &body attribute to set the contents of the body of the mail.

Ohhm Prakash
  • 9
  • 1
  • 3