ASP advanced article online Management update (VI)

Source: Internet
Author: User
Tags exit chr comments continue insert mail
Online ASP Advanced article online Management Update--article forwarding email

Author: Beach Boy

This is one of the main features of this program. In ASP, you can make use of NT SMTP to send Mail Online, but you must confirm that your system has installed the Windows NT Opton PACK SMTP SERVICE, in this article management system is through it to achieve the online transmission of articles, It is only necessary to call the contents of the database and send it to the mailbox.

Here is a description of their implementation of the process, the following is the Mail Send program (sendemail.asp) The specific code and comments:

"Insert Open database Connection file
<!--#include file= "conn.asp"-->
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<title> send articles to email </title>
<body>
<%
"Define related variables
Dim email
Dim Founderr
Dim con
Dim rs,sql
Fouunderr=false
Dim errmsg
Email=trim (Request.Form ("email"))
"Using predefined IsValidEmail functions to determine if email writing is wrong
If IsValidEmail (email) =false Then
errmsg=errmsg+ "<li> your email has errors!</li>"
Founderr=true
End If
%>
<div align=center>
<table border= "0" cellspacing= "0" width= "85%" cellpadding= "0"
height= "class=" "Tableclass" >
<tr>
&LT;TD width= "100%" >
<%
If Founderr=false Then
Dim objcdomail
"Determines what you need to open the recordset article by the ID value returned from list.asp
Set Rs=server.createobject ("Adodb.recordset")
Sql= "SELECT * from article where articleid=" &request ("id")
Rs.Open sql,conn,1,1
"Use Cdonts.newmail to send mail
Set Objcdomail = Server.CreateObject ("CDONTS. NewMail ")
"Here from is the address of the sender, to the address of the addressee, here for the email returned from the list.asp file
Objcdomail.from = "Wodeail@etang.com"
Objcdomail.to =email
"Remove the title field of the article in the specified recordset in the database title do the subject of the message
Objcdomail.subject =rs ("title")
"Remove content from the contents of the article in the specified recordset in the database content, where you can insert your content with" && "
Objcdomail.body = "article title:" &rs ("title") &AMP;CHR (a) &AMP;CHR & "Body:" &rs ("Content") &AMP;CHR (+) & CHR & "Welcome to continue using ASP http://aasp.yeah.net Pioneer Forum &AMP;CHR" &AMP;CHR (a) & "email:wodeail@etang.com"
Objcdomail.send
"Close the connection
Set Objcdomail = Nothing
Rs.close
Set rs=nothing
%>
<p><br></p>
<div align= "center" >
<p><font size= "3" > Article sent successfully, please continue to read the other articles of this site; what's the problem please put it in the forum! </font></p>
<p><font size= "3" > Thank you, as always, for <b><font color= "#FF0000" >asp Moving network pioneer (http://aasp.yeah.net) </ Font></b> support, the building here is inseparable from your comments and suggestions!
</font></p>
</div>
<%
Response.Write "</td></tr></table>"
"If the sending process goes wrong, display an error message
Else%>
<p> <font color= "#FF0000" ><br>
Sorry, your information can not be sent correctly, please double-check the following items are correct:</font>
<ul>
<font color= "#FF0000" ><%response.write errmsg%>
</font>
</ul></td>
</tr>
</table>
</div>
&LT;DD align= "center" >
<div align= "center" ><br>
</div>
</form>
<%
End If
%>

</body>
<%
"To determine whether the email address is correct
function IsValidEmail (email)
Dim names, Name, I, C
IsValidEmail = True
names = Split (email, "@")
If UBound (names) <> 1 Then
IsValidEmail = False
Exit function
End If
For each name in names
If Len (name) <= 0 Then
IsValidEmail = False
Exit function
End If
For i = 1 to Len (name)
c = Lcase (Mid (name, I, 1))
If InStr ("abcdefghijklmnopqrstuvwxyz_-.", c) <= 0 and not IsNumeric (c) Then
IsValidEmail = False
Exit function
End If
Next
If left (name, 1) = "." or Right (name, 1) = "." Then
IsValidEmail = False
Exit function
End If
Next
If INSTR (names (1), ".") <= 0 Then
IsValidEmail = False
Exit function
End If
i = Len (names (1))-InStrRev (names (1), ".")
If I <> 2 and I <> 3 then
IsValidEmail = False
Exit function
End If
If INSTR (email, "...") > 0 Then
IsValidEmail = False
End If

End Function
%>



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.