asfman
android developer
posts - 90,  comments - 213,  trackbacks - 0
<%@Language="JScript" codepage="936"%>
<%
function aspMailClass(){
        var fromMail = "test@test.com";                //发件人邮箱
        var fromServ = "smtp.test.com";                //smtp服务器
        var fromProt = 25;                        //smtp服务器端口
        var fromName = "无忧脚本";                //发件人姓名
        var fromUser = "51js";                        //发件人邮箱用户名
        var fromPass = "51js";                        //发件人邮箱密码
        this.sendMail = function(toEmail, toTitle, toBody){
                try {
                        var byMail = new ActiveXObject("CDO.Configuration");
                        var fields = byMail.Fields;
                        var cfgUrl = "http://schemas.microsoft.com/cdo/configuration/";
                        fields(cfgUrl + "sendusing") = 2;                //这里是发送邮件的端口
                        fields(cfgUrl + "smtpserver") = fromServ;        //smtp服务器
                        fields(cfgUrl + "smtpserverport") = fromProt;        //smtp服务器端口
                        fields(cfgUrl + "smtpaccountname") = fromMail;        //发件人帐号名称
                        fields(cfgUrl + "sendemailaddress") = fromMail;        //发件人的信箱
                        fields(cfgUrl + "smtpauthenticate") = 1;        //是否认证
                        fields(cfgUrl + "sendusername") = fromUser;        //发件人邮箱用户名
                        fields(cfgUrl + "sendpassword") = fromPass;        //发件人邮箱密码
                        fields.Update();
                        var oMail = new ActiveXObject("CDO.Message");
                        with(oMail){
                                To = toEmail;
                                Subject = toTitle;
                                HTMLBody = toBody;
                                From = fromName + "<" + fromMail + ">";
                                Configuration = byMail;
                                Mimeformatted = true;
                                AutoGenerateTextBody = true;
                                Fields.Update();
                                HTMLBodyPart.Charset = "gb2312";
                                Send();
                        }
                        oMail = null;
                        fields = null;
                        byMail = null;
                        return this.result = "邮件成功发送至" + toEmail + "!";
                }
                catch(e) {
                        return this.result = "发送至" + toEmail + "的邮件发送失败!失败原因:" + e.description;
                }
        }
}

//实例
var toMail = new aspMailClass();
toMail.sendMail("xxx@xxx.com", "欢迎来到无忧脚本", "主题<font color=red>主题2</font>");
Response.Write(toMail.result);
toMail = null;
%>
posted on 2007-06-16 15:30 汪杰 阅读(431) 评论(0)  编辑 收藏 引用 所属分类: asp(javascrpt)
只有注册用户登录后才能发表评论。

<2024年12月>
24252627282930
1234567
891011121314
15161718192021
22232425262728
2930311234

常用链接

留言簿(15)

随笔分类(1)

随笔档案(90)

文章分类(727)

文章档案(712)

相册

收藏夹

http://blog.csdn.net/prodigynonsense

友情链接

最新随笔

搜索

  •  

积分与排名

  • 积分 - 468991
  • 排名 - 6

最新随笔

最新评论

阅读排行榜

评论排行榜