用JavaScript + jMail發郵件

來源:互聯網
上載者:User

代碼如下,但還要加入jMail.dll並且註冊它,可以到 http://www.fly263.com/Soft/ShowSoft.asp?SoftID=4 下載一個。

也可以到本人的資源裡找,下載以后里面有一個 install.bat 檔案雙擊就可以把jMail.dll等檔案複製到c:/windows/system32裡並且註冊它,然後就可以用JavaScript發郵件了。

<html>

<head>

    <title>mail</title>

    <script>

    function SendEMail(subject,infor)

    {

        var jMail = new ActiveXObject("Jmail.message");   

        jMail.Silent = true;

        jMail.Charset = "gb2312";  

        jMail.FromName = "from name"    //寄件者

        jMail.From = "from EMail";   //發送人的郵件地址

        jMail.AddRecipient("to EMail");  //收件者的郵件地址

        jMail.Subject = subject;            //要發送的郵件主題

        jMail.Body = infor;             //要發送的郵件資訊

        jMail.MailServerUserName="from user name";              //寄件者郵箱登陸名

        jMail.MailServerPassWord="password";        //寄件者郵箱登陸密碼

        var ret = jMail.Send("smtp.163.com");  //寄件者的stmp伺服器位址

        if(ret == false)

        {

            alert("發送失敗");

        }

        else

        {

            alert("發送成功");

        }

        jMail.Close();

    }

SendEMail('title','body');

       

        </script>

    </head>

   

</html>

函數名:SendMail

'作 用:用Jmail組件發送郵件

'參 數:MailtoAddress -----收信人信箱

' MailtoName -----收信人姓名

' Subject -----主題

' MailBody -----信件內容

' MailFrom -----發信人信箱

' FromName -----發信人姓名

' Priority -----信件優先順序

' MailServerUser -----登陸信箱使用者名

' MailServerPass -----登陸郵箱密碼

' MailDomain -----郵箱網域名稱

' MailServer -----發件SMTP伺服器

'**************************************************

Function SendMail(MailtoAddress,MailtoName,Subject,MailBody,MailFrom,FromName,MailServerUser,MailServerPass,MailDomain,MailServer)

' on error resume next

Dim JMail,JMailstat

Set JMail=Server.CreateObject("JMail.Message")

if err then

err.clear

Response.Write "組件檢測失敗"

JMail.close()

Set JMail=nothing

exit function

end if

JMail.Charset="gb2312" '郵件字元集

JMail.silent=True '忽略錯誤

JMail.ContentType = "text/html" '郵件編碼

JMail.AddRecipient MailtoAddress,MailtoName '收件者地址

JMail.ReturnReceipt = True '是否收條(驗證中)

JMail.From = MailFrom '寄件者郵箱

JMail.MailDomain=MailDomain '郵箱所在網域名稱(驗證中)

JMail.FromName = FromName '寄件者姓名

JMail.MailServerUserName=MailServerUser '信箱使用者名

JMail.MailServerPassWord=MailServerPass '郵箱密碼

JMail.Subject=Subject '郵件主題

JMail.Body=MailBody '郵件內文(純文字格式)

'JMail.HMTLBody=MailBody '郵件內文(HTML格式)

JMail.Priority=1 '郵件等級,1為加急,3為普通,5為低級

JMailstat=JMail.Send(MailServer)

If JMailstat then

response.write "成功"

else

response.write "失敗"

end if

JMail.close()

Set JMail=nothing

End Function

說明:

本文來源:http://www.pczs120.cn/articleshow.asp?artid=46

JMail4.5組件下載及中文操作手冊下載詳見http://www.pczs120.cn/softview.asp?softid=40v

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.