Asp+jmail implementation to send mail _ application Tips

Source: Internet
Author: User

This article uses the ASP and the JMail to realize sends the mail, everybody is not very curious this is how realizes of Na, and small arranges together a to find out!

Global.asa file
What is a Global.asa file? It is actually an optional file where program writers can specify event scripts and declare objects with session and application scopes. The contents of this file are not intended to be displayed to the user, but are used to store event information and objects that are used globally by the application. The name of the file must be global.asa and must reside in the application's root directory. There can be only one Global.asa file per application. The contents are as follows:

<script language= "VBScript" runat= "Server" >
sub Application_OnStart ' initializes the current number of people online and the total amount of access.
Application ("online") =0
Application ("counter") =0 End
Sub
Sub Session_OnStart
session.timeout=5 ' Set the page expiration time to 5 minutes
Application.Lock application ("
online") =application ("online") +1
Application ("Counter" ) =application ("Counter") +1
Application.UnLock End
Sub
Sub Session_OnEnd
Application.Lock
Application ("online") =application ("online")-1
Application.UnLock End
Sub
</script>

Call the page code. test.asp

<% ' increases current number limit processing, prompts trainees, and sends mail ' parameter description ' Subject: message header ' MailAddress: Address of the sender server, such as smtp.163.com ' email: recipient email address ' S  Ender: Sender Name ' content: Message content ' Fromer: Sender's email address Sub sendaction (subject, email, sender, Content) Set JMail = Server.CreateObject ("Jmail.message") Jmail.charset = "gb2312" message character set, default to "us-ascii" jmail.from = Strmailuser ' Sender address Jmai
l.fromname = Sender ' sender name Jmail.subject =subject jmail.mailserverusername = Strmailuser ' Authenticated user name Jmail.mailserverpassword = Strmailpass ' authenticated password jmail.priority = 3 ' Send message type 1 to Super 3 for normal jmail.addrecipient (email) jmail.bod y = Content jmail.send (strmailaddress) End Sub Dim title,stremail,strmailadress,strsender,strcontent Dim Strmailaddress , Strmailpass,strmailuser,jmail if Application ("online") >=1 Then ' example of calling this sub title = Request ("title") Strcontent = " Hello, the current number of online is "&application" ("online") Strsender = Request ("name") ' sender's name stremail = ' a375267603@163.com ' ' Addressee's mailbox, you can change For other mailboxes strmailaddress = "mail.cdce.cn" ' Outgoing server address   Example: smtp.163.com (for 163 server address) Strmailuser = "zenghai@cdce.cn" ' sender username Strmailpass = ' 8888 ' ' Sender account password call SendAction (title,s tremail,strsender,strcontent) strshowmessage = "Module name: verifystudent[exceeds number limit]| Details: The number of currently logged on examination systems has exceeded the server limit" & Application ("Online") & "", please login later! "End If%>

Through this article to understand the Global.asa file What is, and how to implement the message sent, I hope to help you learn.

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.