首页|操作系统|软件开发|网页制作|媒体动画|数据库|ASP教程|ASP.NET教程|PHP教程|JSP教程|XML教程|建站资料|软件学院|行业资讯|平面设计|网络安全|晒IT论坛|IT人才
  位置: 晒IT >> ASP教程 >> ASP实例教程 >> 正文
 
 
一个免费的邮件列表源程序(三)
一个免费的邮件列表源程序(三)
 
 


   if ( sEmail.search ( /\w+((-\w+)|(\.\w+)|(\_\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0- 9]+)*\.[A-Za-z]{2,5}/ ) != -1 )
      return true;
   else
      return false;
}


// ============================================
// add email to database
// ============================================
function AddEmail ( sEmail )
{       
   // open the connection
   DBInitConnection ( );

   // first see if they are already subscribed
   var sSQL = 'SELECT Email FROM MailingList WHERE Email="' + sEmail + '";';

   DBGetRecords ( sSQL );

   if ( !oRecordSet.EOF )
   {
      Out ( '<h5><font color="red">' + sEmail + ' is already subscribed to my mailing list!</font></h5>' );
      return;
   }

   // this section needs more work - what should be done is that an email is
   // sent to the email address, and only added to the database when we
   // get a reply. that way we know the address is valid and the recipient
   // really wants to join the list. for now though, we'll add to the db now.
   sSQL = 'INSERT INTO MailingList (Email) VALUES ("' + sEmail + '");';

   oConnection.Execute( sSQL );

   // free the connection
   DBReleaseConnection ( );

   Out ( sEmail + ' has been successfully subscribed to my mailing list. ' );
   Out ( '<p>You will now receive an email whenever I write new articles, or if I make an important update to any.' );

   Email ( 'Joined the ShawThing mailing list', sEmail, 'You have successfully subscribed to the mailing list at ShawThing. If you didn\'t request this please reply to this email, or visit http://www.shawthing.com/subscribe.asp to unsubscribe.\n\nThank you.\n\nJames Shaw\nhttp://www.shawthing.com/' );
}


// ============================================
// remove email from database
// ============================================
function RemoveEmail ( sEmail )
{       
   // open the connection
   DBInitConnection ( );

   // first see if they are already subscribed
   var sSQL = 'SELECT Email FROM MailingList WHERE Email="' + sEmail + '";';

   DBGetRecords ( sSQL );

   if ( oRecordSet.EOF )
   {
      Out ( '<h5><font color="red">' + sEmail + ' isn\'t subscribed to my mailing list!</font></h5>' );
      return;
   }

   // delete from the database
   sSQL = 'DELETE FROM MailingList WHERE Email="' + sEmail + '";';

   oConnection.Execute( sSQL );

   // free the connection
   DBReleaseConnection ( );

   Out ( sEmail + ' has been successfully removed from my mailing list. ' );
   Out ( '<p>You have been sent a confirmation email, but after that you will not receive any more emails.' );

   Email ( 'Removal from ShawThing mailing list', sEmail, 'You have been successfully removed from the mailing list at ShawThing. If you didn\'t request this please reply to this email, or visit http://www.shawthing.com/subscribe.asp to re-subscribe.\n\nThank you.\n\nJames Shaw\nhttp://www.shawthing.com/' );
}


// ============================================
// email me!
// ============================================
function Email ( sSubject, sEmail, sMessage )
{   // send an email to the address just to confirm what just happened
   var oMail = Server.CreateObject ( "CDONTS.NewMail" );

   // setup the mail
   oMail.From = 'DB@shawthing.com';

   oMail.To = sEmail;
   oMail.Importance = 1;

   oMail.Subject = sSubject;
   oMail.Body = sMessage;

   // send it
   oMail.Send ( );

   // release object
   oMail = null;
}
%>
     
utils/Database.asp
<%
// globals
var oConnection;
var oRecordSet;
  • 上一篇: 用密码保护页面 (I)
  • 下一篇: 一个免费的邮件列表源程序(二)
  •  告诉好友  打印此文 关闭窗口 返回顶部
     
    热点文章
     
     
    推荐文章
     
     
    相关文章

    | 设为首页 | 加入收藏 | 联系我们 | 友情链接 | 诚聘英才 |
    Copyright© 2008 ShaiIT.Com .All Rights Reserved
    下载alexa工具,提升您的网站排名