ASP + jmail send mail

Source: Internet
Author: User
Alas, no ASP, but the company wants me to maintain an ASP platform now,

Haha, it is also a challenge. Here, I would like to thank you for your experience and take care of ASP beginners,

Second, you can find the answer again later.

This is the requirement. When the number of online users reaches a certain number, the system prompts and sends an email.

 

Global. Asa file,

What is a global. Asa file? It is actually an optional file,ProgramThe writer can specify event scripts in the file and declare objects with sessions and application scopes. The content of this file is not used to display to users, but to store event information and objects globally used by applications. The file name must be global. Asa and be stored in the root directory of the application. Each application can have only one global. Asa file. The content is as follows:

<Script language = "VBScript" runat = "server">
Sub application_onstart 'initializes the current number of online users and total access volume.
Application ("online") = 0
Application ("counter") = 0

End sub

Sub session_onstart
Session. Timeout = 5' set the webpage 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 pageCode. Test. asp
<%

'increase the current number of students, prompt students, and send an email
'parameter description
'subject: Mail title
'mailaddress: the sender server address, such as smtp.163.com
'email: recipient email address
'sender: sender name
'content: email content
'fromer: sender's email address
sub sendaction (subject, email, sender, content)
set jmail = server. createobject ("jmail. message ")
jmail. charset = "gb2312" 'character set, default: "US-ASCII"
jmail. from = strmailuser' sender address
jmail. fromname = sender 'sender name
jmail. subject = subject
jmail. mailserverusername = strmailuser' user name for authentication
jmail. mailserverpassword = strmailpass' password for authentication
jmail. priority = 3' the type of the sent mail 1 is the top grade 3 is normal
jmail. addrecipient (email)
jmail. body = 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 users is" & Application ("online ")
Strsender = request ("name") 'sender name
Stremail = "a375267603@163.com" 'recipient's mailbox, can be changed to other mailbox
Strmailaddress = "mail.cdce.cn" 'sending server address example: smtp.163.com (for the 163 server address)
Strmailuser = "zenghai@cdce.cn" 'sender User Name
Strmailpass = "8888" 'sender account password
Call sendaction (title, stremail, strsender, strcontent)
Strshowmessage = "module name: verifystudent [number of students exceeded] | details: the number of students currently logged on to the examination system has exceeded the server limit [" & Application ("online ")&"], please log on later! "
End if

%>

 

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.