上一篇:使用W3 JMail实现邮件发送的解决方案(1) >>
用ASP发电子邮件
<%
Dim strTo, strSubject, strBody @#Strings for recipient, subject, boby
Dim objCDOMail @#The CDO object
@#First we@#ll read in the values entered
strTo = Request.Form("to")
@#These would read the message subject and body if we let you enter it
@#strSubject = Request.Form("subject")
@#strBody = Request.Form("body")
strSubject = "Sample E-mail sent from X-Bit!"
@# This is multi-lined simply for readability
strBody = "This message was sent from a sample at X-Bit. "
strBody = strBody & "It is used to show people how to send e-mail from an "
strBody = strBody & "Active Server Page. If you did not request this "
strBody = strBody & "e-mail yourself, your address was entered by one of "
strBody = strBody & "our visitors. We do not store these e-mail addresses."
strBody = strBody & " Please address all concerns to pplo@sina.com."
@#Ok we@#ve got the values now on to the point of the script.
@#We just check to see if someone has entered anything into the to field.
@#If it@#s equal to nothing we show the form, otherwise we send the message.
@#If you were doing this for real you might want to check other fields too
@#and do a little entry validation like checking for valid syntax etc.
If strTo = "" Then
%>
<FORM ACTION="./email_cdo.asp" METHOD="post">
Enter your e-mail address:<BR>
<INPUT TYPE="text" NAME="to" SIZE="30"></INPUT>
<!-- These would be used if we decided to let you edit them
Subject:
<INPUT TYPE="text" NAME="subject" SIZE="30"></INPUT><BR>
Message:
<TEXTAREA NAME="body" ROWS="10" COLS="40" WRAP="virtual"></TEXTAREA><BR>
-->
<INPUT TYPE="submit" VALUE="Send Mail!"></INPUT>
</FORM>
<%
Else
@# Create an instance of the NewMail object.
Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
@# Set the properties of the object
objCDOMail.From = "ppop@sina.com"
objCDOMail.To = strTo
objCDOMail.Subject = strSubject
objCDOMail.Body = strBody
@# There are lots of other properties you can use.
@# You can send HTML e-mail, attachments, etc...
@# You can also modify most aspects of the message
@# like importance, custom headers, ...
@# Check the documentation for a full list as well
@# as the correct syntax.
@# Some of the more useful ones I@#ve included samples of here:
@#objCDOMail.Cc = "kola100@163.com;kola100@163.com"
@#objCDOMail.Bcc = "wwew@sina.com;wwew@sina.com"
@#objCDOMail.Importance = 1 @#(0=Low, 1=Normal, 2=High)
@#objCDOMail.AttachFile "c:\file.txt", "file.txt"
@# Send the message!
objCDOMail.Send
@# Set the object to nothing because it immediately becomes
@# invalid after calling the Send method.
Set objCDOMail = Nothing
Response.Write "Message sent to " & strTo & "!"
End If
%>
下一篇:CDONTS.NewMail 的成员(方法、属性…) >>
相关文章:
- · 利用CDONTS发送邮件的ASP函数
- · 用HTML格式发送邮件
- · 如何利用ASP实现邮箱访问
- · IMail基础教程(五) 用WEB方式收发邮件
- · IMail基础教程(四) 用POP3方式收发邮件
- · IMail基础教程(三) 建立可用的电子邮件地址
- · IMail基础教程(二) 安装IMail
- · IMail基础教程(一) DNS设置 - 2
- · IMail基础教程(一) DNS设置 - 1
- · 邮件服务器端软件-IMAIL基础教程
- · 用ASPMail组件实现E_mail自动反馈
- · jmail4.1用pop3收信的例子
- · 用ASP发送HTML格式的邮件
- · 在Windows桌面上使用WSH接收邮件
- · 如何在ASP+中发送邮件
- · asp电子报制作与程序
- · 如何使用FSO搜索硬盘文件
- · 使用函数自动生成n层目录
- · FSO操作示例(给初学者)
- · 同文件夹内文本搜索器(vbs)
- · 一个实用的FSO-实时统计在线人数
- · 如何获知页面上的图象的实际尺寸?
- · 使用FSO把文本信息导入数据库
- · 在ASP中使用FSO组件生成HTML页面
- · 用asp实现的代码批量修改程序,fso相关
- · fso实例
- · 硬盘文件搜索代码(ASP类)
- · 遍历目录以及目录下文件的函数
- · vithink小文件自动实现文件浏览下载
- · 用asp实现的代码批量修改程序,fso相关
- · fso实例
- · 使用FSO把文本信息导入数据库
- · 在线实时开通FTP&WEB
- · 对文件的操作--建立移动删除文件夹
- · 一个实用的FSO-实时统计在线人数
- · 利用FSO取得BMP,JPG,PNG,GIF文件信息
- · 三种禁用FileSystemObject组件的方法
- · 遍历目录以及目录下文件的函数
