views:

43

answers:

2

Hi,

with ActiveX I can create an Outlook instance and start a new HTML e-Mail.

Here is the sample code:

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

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

mailFolder = nameSpace.getDefaultFolder(6);

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

mailItem.Subject="a subject test";

mailItem.To = "[email protected]";

mailItem.HTMLBody = "<b>bold</b>";

mailItem.display (0);

Is there an equivalent for Firefox. For example with XPCom? Has anyone a sample please?

Thank you!

A: 
//this class emulates the one u used to use
function mailer() {
  this.display = function() {
    var url = 'mailto:'
                       + this.To
                       + '?subject=' + encodeURIComponent(this.Subject)
                       + '&body=' + encodeURIComponent(this.HTMLBody);
    window.location = url;
  }
}

//we instantiate
mailItem = new mailer();


//and then your old code: 
mailItem.Subject="a subject test";
mailItem.To = "[email protected]";
mailItem.HTMLBody = "<b>bold</b>";
mailItem.display (0);

What is being done here is using <a>'s mailto: similar approach:

<a href="mailto:[email protected]?subject=a+subject+test&body=%3Cb%3Ebold%3C/b%3E">email me!</a>
aularon
Have you already tested this code? I think it will not work for Outlook. The mailto body has to be in plain/text and not in html. (RFC definition) Outlook will print the HTML Code readable.Any other solutions?
Mimefilt
I tested it, but I have html disabled on my thunderbird so I didn't notice that. I can't think of another solution, however I found this page: http://www.angelfire.com/dc/html-webmaster/mailto.htm that talks about using forms with `"mailto:"` action: `<FORM method="post" action="mailto:[email protected]" enctype="text/plain">` try with that changing `text/plain` to `text/html`, I am not sure how standard is that or whether it works with HTML, but it worths giving a shot. (you can construct a temporary form with javascript and submit it, but of course try first with html to ensure it works).
aularon
Thanks for your answer. The "normal" link is not working for outlook. (It will work for **some** thunderbird versions, but not for outlook) I'll try the form solution on Monday.
Mimefilt
I'm afraid. No luck )= Has anyone an other solution please
Mimefilt
A: 
Mimefilt