文本到Outlook正文 [英] Text to Outlook body

查看:139
本文介绍了文本到Outlook正文的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有此按钮,单击该按钮可打开带有我提供的详细信息的Outlook.我也有一个TEXTAREA,其中包含某些文本.我正在寻找一种使此文本出现在我的外观中的方法.能做到吗?请在下面找到代码-

I have this button which when clicked opens outlook with the details i have provided. I also have a TEXTAREA which is holding certain texts. I'm looking for a way to have this text appear in the body of my outlook. Can this be done.? Please find code below -

     <!DOCTYPE html>
<html lang="en">
<head>
<body>
  <title>NMUK</title>
  <script type="text/javascript" language="javascript" src="Mail.js"></script>




  <script src="http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"></script>
  <script type="text/javascript">
    $(function () {
      $('.btnSendEmail').click(function (event) {
        var email = 'example@email.com';
        var subject = 'Creation Checklist';
        var emailBody = $('#holdtext').val();
        window.location = 'mailto:' + email + '?subject=' + subject + '&body=' + emailBody;
      });
    });
  </script>
</head>


  </head>
  <br><br><br><br><br><br>
  <div id="container">
<TEXTAREA ID="holdtext" rows="15" cols="100">
</TEXTAREA><br><br>

<button class="btnSendEmail" ><span>Send Email</span></button>
</div>

<div>



<style>#container {width:100%; text-align:center;}</style>

  <h2></h2><br><br><br>
 <p>  <SPAN ID="Fetch"> Fetch next</p> <br>      

 <button class="button2" button onclick="FetchFunction()"><span>Next  </span></button>


  <p>  <SPAN ID="GroupCompanies"> In AD goto Group</p>       

 <button class="button1" button onclick="GroupCompaniesFunction()"><span>Next  </span></button>



 <script>
function FetchFunction() {    
holdtext.innerText = Fetch.innerText;
}

function GroupCompaniesFunction() {    
holdtext.innerText += "\n"+GroupCompanies.innerText;
}
</script>




</body>


</html>

推荐答案

尝试更改此行:

var emailBody = 'Body';

收件人:

var emailBody = $('#holdtext').val();

因为textarea是表单元素..val()是在其中检索文本的正确方法.

Because textarea is a form element.. val() is the proper way to retrieve the text inside of it.

让我知道这是否有帮助!

Let me know if this helps!

更新

要保留换行符,请更改此行:

To preserve the line breaks.. change this line:

window.location = 'mailto:' + email + '?subject=' + subject + '&body=' + emailBody;

收件人:

window.location = 'mailto:' + email + '?subject=' + subject + '&body=' + encodeURIComponent(emailBody);

这篇关于文本到Outlook正文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆