ASP Advanced Tutorial Ⅹ: Guest Book automatically send e-mail

Source: Internet
Author: User
Tags 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:winntsystem32 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:winntsystem32 the MS-DOS mode:
C:winntsystem32>regsvr32 Cdonts.dll
(If we want to use the command: c:winntsystem32>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:cwjgo-aspguestbook5email.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"
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.