Sending email (outlook) with javascript

Asked

Viewed 1,033 times

0

I found a code that makes the outlook open, but when I insert it into my code it does not work.

BELOW THE CODE I FOUND

<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
<div id="mailBody"><table border=1> <tr><td>blabla</td></tr> </table></div>
<input type="tex" name="email" id="email">
<input type="tex" name="email2" id="email2">
<textarea name="teste"></textarea>
<input type="button" onclick="SendEmail();">

<script type="text/javascript">
    function SendEmail(){
    var outlookApp = new ActiveXObject("Outlook.Application");
    var nameSpace = outlookApp.getNameSpace("MAPI");
    mailFolder = nameSpace.getDefaultFolder(6);
    mailItem = mailFolder.Items.add('IPM.Note.FormA');
    mailItem.Subject = "Me";
    mailItem.To = email.value + ";" + email2.value;
    mailItem.HTMLBody = teste.value;
    mailItem.display(0);
    }
</script>
</html>

NOW MY CODE

<textarea name="textarea1" id="textarea1" rows="5" cols="40" id="salvar"></textarea>
        <input name="save" type="button" value="ADD CONTEINER"
           onclick="saveValues(); return false"/>
        &#0160;
        <input type="button" value="Enviar e-mail (outlook)" onclick="SendEmail(); return false">

function SendEmail(){
        var outlookApp = new ActiveXObject("Outlook.Application");
        var nameSpace = outlookApp.getNameSpace("MAPI");
        mailFolder = nameSpace.getDefaultFolder(6);
        mailItem = mailFolder.Items.add('IPM.Note.FormA');
        mailItem.Subject = "Novo pedido";
        mailItem.To = email_pag1.value;
        mailItem.HTMLBody = textarea1.value;
        mailItem.display(0);
    }

I don’t understand why it’s not working!

  • Dude, use code formatting. In the editor you have the {} option, you select it and put your code inside

  • Your code is inside the tags script or are lost within HTML as posted here?

  • Are inside the tag script

  • I already found the error. You have to format each line like this: mailItem.Htmlbody = Document.getElementById('textarea1'). value;

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.