如何使用html发送邮件 [英] How to Send mail by using html

查看:87
本文介绍了如何使用html发送邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



谁能给我有关如何使用HTML代码或javascript代码发送电子邮件的示例.
有任何链接或示例程序吗?

谢谢,
Sampath.

Hi,

Can anyone give me example on how to send email using HTML code or javascript code.
Any links or sample program?

Thanks,
Sampath.

推荐答案

如果您使用的是Asp.Net,请使用Javascript Ajax回发并从服务器端发送电子邮件.您可以使用XmlHttpObject或JQuery实现此目的.如果您使用的是纯HTML和Javascript应用程序,请尝试使用SendGrid REST API.以下是SendGrid网站的网址.


http://sendgrid.com/documentation/display/api/Web [
If you are using Asp.Net then use Javascript Ajax postback and send email from server side. You can achieve this using XmlHttpObject or JQuery. In case you are working on pure HTML and Javascript application then try SendGrid REST API. Below is SendGrid website url.


http://sendgrid.com/documentation/display/api/Web[^]

Sample code is like below.

<script language="javascript" type="text/javascript">
    function Sendmail() {

        if (document.getElementById("TxtFrom").value == "" || document.getElementById("TxtTo").value == "" || document.getElementById("TxtSub").value == "" || document.getElementById("TxtBody").value == "") {
            alert("Fields cant not be empty!");
        }
        else {
            var restURL = "https://sendgrid.com/api/mail.send.xml?api_user=UserRegistrationEmail@domain.com&api_key=ApiKeyValue&to=" + document.getElementById("TxtTo").value + "&toname=Destination&subject=" + document.getElementById("TxtSub").value + "&html=" + document.getElementById("TxtBody").value + "&from=" + document.getElementById("TxtFrom").value;
            window.open(restURL, 'sendgrid', 'width=400,height=200');

            //window.location.href = maill;
            alert("Mail sent successfully!");
        }
    }
</script>


您无法通过HTML做到这一点.使用ASP.NET

在ASP.NET中发送电子邮件 [
You can''t do that by HTML. use ASP.NET

Sending Email in ASP.NET[^]


检查相同的讨论
Check the same discussion here[^]


这篇关于如何使用html发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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