服务的大大小小的网站都有他们自己的邮件服务器,但并非每个都那么慷慨地免费提供给我们的这个小程序使用,Yahoo!不可以,但163的可以,也就是说,为了完成我们这个程序,你应该注册一个163邮件或找到其他免费的。我们假设你的邮件地址是"abc@163.com",密码为"yourpassword"
3,CDO.Message对象:
代表了我们要发送的邮件对象。CDO.Message msg = new Message();
msg.Form:发件人邮件地址
msg.T收件人邮件地址
msg.Subject:邮件标题
msg.HtmlBody:邮件主体,比如"<html><body>" + "邮件信息" + "</body></html>";
msg.AddAttachment():添加附件
msg.Send():发送邮件
4,其他设置:
1 CDO.IConfiguration iConfg = msg.Configuration;
2 ADODB.Fields oFields = iConfg.Fields;
3
4 oFields["http://schemas.microsoft.com/cdo/configuration/sendusing"].Value = 2;
5 oFields["http://schemas.microsoft.com/cdo/configuration/sendemailaddress"].Value = "abc@163.com";
6 oFields["http://schemas.microsoft.com/cdo/configuration/smtpaccountname"].Value = "abc@163.com";
7 oFields["http://schemas.microsoft.com/cdo/configuration/sendusername"].Value = "abc";
8 oFields["http://schemas.microsoft.com/cdo/configuration/sendpassword"].Value = "yourpassword";
9 oFields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"].Value = 1;
10 oFields["http://schemas.microsoft.com/cdo/configuration/languagecode"].Value = 0x0804;
11 oFields["http://schemas.microsoft.com/cdo/configuration/smtpserver"].Value = "smtp.163.com";
12
13 oFields.Update();
14 this.oMsg.BodyPart.Charset = "gb2312";
15 this.oMsg.HTMLBodyPart.Charset = "gb2312";
5,成果:
6.Demo下载:
在这里下载示例程序以及源代码
下面是提交表单后的save.asp页面代码 请帮忙添加修改发送邮件到指定邮箱功能,有JMAILA插件,多谢了!
<%
username=Trim(Request.Form("username"))
mobile=Trim(Request.Form("mobile"))
address=Trim(Request.Form("address"))
product=Trim(Request.Form("product"))
QQ=Trim(Request.Form("QQ"))
gbook=Trim(Request.Form("gbook"))
dim ranNum,Summer 'Summer为自定义的定单号。。
randomize
ranNum = int(90000*rnd)+10000
Summer = year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum
set rs=server.CreateObject("adodb.recordset")
rs.Open "select * from [User_Tui] ",conn,1,3
rs.addnew
rs("username")=trim(request("username"))
rs("mobile")=trim(request("mobile"))
rs("address")=trim(request("address"))
rs("QQ")=trim(request("QQ"))
rs("product")=Trim(Request.Form("product"))
rs("gbook")=Trim(Request.Form("gbook"))
rs("pay")=Trim(Request.Form("pay"))
rs("ordernum")=Summer
rs("regtime")