找回密码
 注册
搜索
热搜: 回贴
  • 前程无忧官网首页 有什么好的平台可以
  • 最新的销售平台 互联网营销的平台有哪
  • 制作网页的基本流程 网页制作和网页设
  • 【帝国CMS】输出带序号的列表(数字排
  • 网站建设公司 三一,中联,极东泵车的
  • 织梦 建站 织梦网站模版后台怎么更改
  • 云服务官网 哪些网站有免费的简历模板
  • 如何建网站要什么条件 建网站要用什么
  • 吉林市移动公司电话 吉林省退休人员网
  • 设计类毕业论文 网站设计与实现毕业论
查看: 218|回复: 2

用ASP发电子邮件

[复制链接]
发表于 2009-5-3 04:20:59 | 显示全部楼层 |阅读模式 IP:江苏扬州
用ASP发电子邮件

用ASP发电子邮件
lt;%
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
%>



   文章来源: http://bbs.1teng.net
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|小黑屋|最新主题|手机版|微赢网络技术论坛 ( 苏ICP备08020429号 )

GMT+8, 2024-9-29 13:31 , Processed in 0.267827 second(s), 13 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表