ASP: Guest Book automatically send e-mail

Source: Internet
Author: User
Tags copy mail web database
ASP itself does not have the ability to send mail, but if you want to use ASP to send e-mail (for example: You have a message, just want to let those in your message book left a statement on the Internet users know that you want the Internet users to fill in your message book completed, Your guest book will automatically e-mail the message to the Internet users of the message, then you need to install an ASP component. And the use of these components to help you achieve the automatic mail send, reply and so on.


If your ASP and Web database is running on IIS4 (Internet Information Server 4.0), you can use CDONTS.DLL. If you have already installed the default NT 4.0 Option pack,cdonts. The DLL is stored under your machine's C:\Winnt\System32\ directory. With this component we can't apply it right away, we have to complete the registration of the component before we apply it, so how can we register the CDONTS.DLL? We can enter in the CDONTS.DLL directory C:\Winnt\System32\ the MS-DOS mode:
C:\winnt\system32>regsvr32 Cdonts.dll
(If we want to use the command: c:\winnt\system32>regsvr32/u Cdonts.dll)


Now that we have finished registering the component, we can begin to explain how to use the component. We can use the following simple script to the guest book to add automatic e-mail function.

<%
Dim Mailobject
Dim Email
email = request.form ("email")
Set mailobject = Server.CreateObject ("CDONTS. NewMail ")
Set mymail = Server.CreateObject ("CDONTS. NewMail ")
Mymail.subject = "You are welcome to come again next time"
Mailobject.send "Your own e-mail", Email, "You are welcome to give us a message next time." "Mymail.send
Set mymail=nothing
%>
The above code copy to the manage2.asp, a simple e-mail through the ASP to send the guest book is realized. You may not be satisfied with the way the e-mail is sent, for the simple reason that: because in order to thank your netizens for your support, you last night to write a full thousands of words (perhaps I said less) of the gratitude of words, this morning to find that the original book is not the same as the function of the attachment, see, this is more irritating. Fortunately, the original CDONTS.DLL can also be used to send attachments, without further ado, we will immediately dedicate it out. <%
Dim Mailobject
Dim Email email = Request ("email")
Set mailobject = Server.CreateObject ("CDONTS. NewMail ")
Att_file= "D:\cwj\GO-asp\guestbook5\email.txt"
F_name= "Email.txt"
Mailobject.from= "Your own e-mail"
Mailobject.to = Email
mailobject.subject= "Thank you for your support for our work"
mailobject.body= "Thank you for your support for our work"
Mailobject.attachfile Att_file,f_name
Mailobject.send
%>


Just copy the above code down to replace the first instance, our guest book will be able to implement the automatic attachment function. What is worth our attention here is: att_file= "D:\cwj\GO-asp\guestbook5\email.txt"
Must be the absolute path of our attachment. In fact, in addition to the CDONTS.DLL component, there are many components developed by Third-party vendors you can also use. For example, it is said that even Intel Corporation is using Aspmail components and seemingly popular W3 jmail and so on. Can be welcomed by everyone, the original by the words and declared, we can directly from the following places to download them.
Aspmail Component Download Address: http://www.flicks.com/ASPMail/intro.htm
JMail Component Download Address: Http://download.dimac.net/jmail/jmail.exe

To be practical, my first use of an ASP to send an e-mail message to a guest book is the Aspmail component (naturally because I hear that even Intel Corporation is using it). Since the use of it, nature will have some understanding of it, I think here also may wish to make a simple introduction to the use of aspmail components.


The application of the Aspmail component is also very simple, first of all, we have to install the component, after installation in the Aspmail of the installation directory will be accompanied by sample example, we just control these examples, and then slightly change. I have provided an example here for everyone, and separately will use the component when all the other files involved in the Aspmail directory, you can download from the download area after the study, I just a little bit for a brief explanation.
First, we enter <!--in manage2.asp #include file= "aspmail/sendmail2.asp"--> and Save as manage3.asp, and the script for the specific sendmail2.asp is as follows:
<%
Set Mailer = Server.CreateObject ("Aspmail. ASPMAILCTRL.1 ")
%>
<%
Name = Request.Form ("name")
email = request.form ("email")
Subject = "You are welcome to come again next time"
Memo = "You are welcome to leave a message next time!" "
MailServer = "Smtp.21cn.com"
result = Mailer. SendMail (mailserver, name, email, subject, memo)
%>
It is worth noting here: MailServer = "smtp.21cn.com" is filled out in the SMTP server, I used the 21st century SMTP mail server as an example, of course, you can also use the other place or your own (really envy the evil person), It is very important that you fill in the correct and make sure that they are indeed open to the service. As to why I finally gave up the use of this component, after everyone has used it, it is likely that I will not be in the minority, for the simple reason that the free component will hate to put a few words under every letter you send to urge you to hurry up and buy its registered version.

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.