发邮件的asp(CDONTS.NewMail)

2016-02-19 09:40 31 1 收藏

今天图老师小编要跟大家分享发邮件的asp(CDONTS.NewMail),精心挑选的过程简单易学,喜欢的朋友一起来学习吧!

【 tulaoshi.com - Web开发 】

formmail.htm
代码如下:

html
head
meta http-equiv="Content-Type" content="text/html; charset=gb2312"
title提交表单发送邮件/title
/head

body
table width="97%" border="1" cellspacing="5" cellpadding="1" style="text-align:center" bgcolor="#EEFFF4" height="630"
  tr
    td height="440"
      form action="sendMail.asp" target="_blank" method=post
        input name="mailTo" type=hidden value="dayechg@163.com"
        input name="title" type="hidden" id="title" value="网上预定"
        table border=0 cellpadding=9 cellspacing=0 
                                width="100%"
          tbody
            tr
              td width="44%"
                div align=leftfont size="2" color="#0000FF"姓  名:/font /div/td
              td width="56%"
                div align=leftfont size="2" color="#0000FF"
                  input name=姓名
              /font /div/td
            /tr
            tr
              td width="44%"
                div align=leftfont size="2" color="#0000FF"性  别:/font /div/td
              td width="56%"
                div align=leftfont size="2" color="#0000FF"男
                      input CHECKED 
                                name=性别 type=radio value=男
                  女
                  input name=性别 
                                type=radio value=女
              /font /div/td
            /tr
            tr
              td width="44%"
                div align=leftfont size="2" color="#0000FF"年  龄:/font /div/td
              td width="56%"
                div align=leftfont size="2" color="#0000FF"
                  input name=年龄
                  */font /div/td
            /tr
            tr
              td width="44%"
                div align=leftfont size="2" color="#0000FF"联系电话:/font /div/td
              td width="56%"
                div align=leftfont size="2" color="#0000FF"
                  input name=联系电话
                  */font /div/td
            /tr
            tr
              td width="44%"
                div align=leftfont size="2" color="#0000FF" class="unnamed1"E-mail:/font /div/td
              td width="56%"
                div align=left
                  p class="unnamed1"font size="2" color="#0000FF"
                    input name=Email
                    * /font /p
              /div/td
            /tr
            tr
              td width="44%"font size="2" color="#0000FF"定票 :/font/td
              td width="56%" font size="2" color="#0000FF"
                input name=定票 id="定票" value="请输入详细内容"
              /fontfont color="#0000FF" /font/td
            /tr
            tr
              td width="44%"
                div align=leftfont size="2" color="#0000FF"定餐:/font /div/td
              td width="56%"
                div align=leftfont size="2" color="#0000FF"
                  input name=定餐 id="定餐" value="请输入详细内容"
              /font /div/td
            /tr
            tr
              td width="44%" class="unnamed1"font color="#0000FF"定交通工具:/font/td
              td width="56%"font size="2" color="#0000FF"
                input name=定交通工具 id="定交通工具" value="请输入详细内容"
              /font/td
            /tr
            tr
              td width="44%" class="unnamed1"font color="#0000FF"定房:/font/td
              td width="56%"font size="2" color="#0000FF"
                input name=定房 id="定房" value="请输入详细内容"
              /font/td
            /tr
            tr
              td class="unnamed1"font color="#0000FF"定导游:/font /td
              tdfont size="2" color="#0000FF"
                input name=定导游 id="定导游" value="请输入您想定的导游条件"
              /font /td
            /tr
            tr
              td class="unnamed1"font color="#0000FF"定酒店:/font/td
              tdfont size="2" color="#0000FF"
                input name=定酒店 id="定酒店" value="请输入详细内容"
              /font/td
            /tr
            tr
              td colspan=2
                div style="text-align:center"font size="2" color="#0000FF"
                  input name=Submit type=submit value=确认
                  input name=reset type=reset value=取消
              /font /div/td
            /tr
          /tbody
        /table
        p /p
    /form/td
  /tr
/table
/body
/html

sendmail.asp
代码如下:

%
  function SendMail(mailTo,mailFrom,title,content)
'    on error resume next
    dim objCDOMail
    Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
    With objCDOMail
      .From =mailFrom
      .To =mailTo
      .Subject =title
      .Body =content
      .BodyFormat =0
      .MailFormat =0
      .Send
    End With
    Set objCDOMail = Nothing
    if err then
      SendMail=False
      err.Clear
    else
      SendMail=True
    end if
  end function

  if request.Form"" then
      mailTo=trim(Request.form("mailTo"))
      mailForm=trim(Request.form("email"))
      title=trim(Request.form("title"))
      content=""
      for each mailKey in Request.form
        content=content&"br" & mailKey & ":" & trim(Request.form(mailKey))
      next
  elseif request.QueryString"" then
      mailTo=trim(Request.QueryString("mailTo"))
      mailForm=trim(Request.QueryString("email"))
      title=trim(Request.QueryString("title"))
      content=""
      for each mailKey in Request.QueryString
        content=content&"br" & mailKey & ":" & trim(Request.QueryString(mailKey))
      next
  else
    response.Write("script language=javascriptalert('请用正确的方式发送Email');window.close();/script")
    response.end
  end if
'  response.Write(content)
'  response.End()
  pdSendMail=SendMail(mailTo,mailForm,title,content)
  if not pdSendMail then
    response.Write("script language=javascriptalert('发送失败');window.close();/script")
  else
    response.Write("script language=javascriptalert('发送成功');window.close();/script")
  end if
%

来源:https://www.tulaoshi.com/n/20160219/1591692.html

延伸阅读
标签: ASP
  其实ASP可以做很多事,只是大家不知道怎么用而以。微软为asp提供了非常多的现成有用的组件,而这些组件却没有人知道,如用CDO.Message发送邮件。 什么是CDO.Message?在winnt和win2k下发送邮件要用CDONTS.NewMail,CDONTS.NewMail组件是需要注册的,很简单,只要在服务器上运行命令行regsvr32 Cdonts.dll,在弹出的对话框中确定即可,...
新浪邮箱怎么发邮件   1)打开手机新浪邮件进入首页后点击右上角图标,编辑好收件人、主题、内容后点击右上角即可发送。     
云邮局怎么发邮件   云邮局怎么发邮件?云邮局也是邮箱类应用,可以收发邮件,在云邮局中可快速发送邮件给好友。接下来小编就教大家云邮局怎么发邮件?云邮局发邮件方法。 1)打开云邮局进入应用后点击下方导航栏,接着点击。 2)在邮箱中点击右上图标,编辑新邮件信息后点击右上角可发送。
标签: ASP
  Click here to copy the Code to your clipboard (Only for IE Users) 'Declare Variables Dim CDONTSObj, MessageBody 'Create the CDONTS object Set CDONTSObj = Server.CreateObject("CDONTS.NewMail") 'To Address CDONTSObj.To = "info@scriptmate.com" 'From Address CDONTSObj.From = "you@yours...
标签: PHP
  <HTML <TITLE UNTITLED </TITLE <?php   include "connect.inc.php"; if ($subject) { $query = "select name,email from user"; $res = mysql_query($query);   $row = mysql_fetch_array($res);   while ($row) { mail($row['email'],$subject,$row['name'].&qu...

经验教程

921

收藏

16
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部