The implementation of the Code sharing in the ASP to send the mail in time _ application skill

Source: Internet
Author: User
Tags function definition email account

Now this project needs to use ASP to do regular mail delivery, many people say that ASP does not have such a function.

In fact, I have in the previous article has done a detailed explanation, but that is a timed task, the basic idea is the same.

Reference: The method of implementing timed tasks in ASP

Here we do this using the JMail component, the content of which is a single Web page and can be customized freely.

Let's take a look at the code sent by the timed message:

Copy Code code as follows:

Function gethttppage (URL)
Dim objxml
Set Objxml=createobject ("MSXML2. serverxmlhttp.3.0 ")" calls the XMLHTTP component, whether the test space supports XMLHTTP
Objxml.open "Get", Url,false ' false means to obtain the code of the Web page in a synchronized way, to understand what synchronization is? What is asynchronous?
Objxml.send () ' Send
Gethttppage=bbytestobstr (objxml.responsebody) ' returns information, with function definition encoding
Set Objxml=nothing ' Off
End Function


Function Bbytestobstr (body)
Dim objstream
Set objstream = CreateObject ("ADODB.stream") '//calling ADODB.stream component
Objstream. Type = 1
Objstream. Mode =3
Objstream. Open
Objstream. Write body
Objstream. Position = 0
Objstream. Type = 2
Objstream. Charset = "GB2312"
' Convert the original default UTF-8 encoding to GB2312 encoding, otherwise directly using the XMLHTTP to invoke the page with Chinese characters will be garbled
Bbytestobstr = objstream. ReadText
Objstream. Close
Set objstream = Nothing
End Function



Sub sendaction (Subject,mailaddress,tomail,sender,content,fromemail,fromer,username,password)
Set ojmail=createobject ("Jmail.message")
Ojmail.logging=false
Ojmail.silent=true
Ojmail.priority = 3
Ojmail.fromname=fromer
Ojmail.from= Fromemail
ojmail.charset= "gb2312"
Ojmail.mailserverusername = UserName
Ojmail.mailserverpassword = PassWord
ojmail.contenttransferencoding = "Base64"
Ojmail.htmlbody = Content ' Message contents
Ojmail.body =content ' "Our messages are in HTML format, but your mail viewing software may not support
Ojmail.addrecipient Tomail ' recipient address
Ojmail.subject = Subject ' title
Ojmail.send (MailAddress)
End Sub




Dim subject,mailaddress,toemail,sender,fromemail,fromer,password,ojmail,usernames,tomail
Dim username,useremail
Dim pass,content
Dim mailname,mailpass,mailform,mailsmtp
Account number of mailname= "XXX" SMTP mailbox
Password for mailpass= "XXX" SMTP mailbox
Signature of mailform= "XXX" SMTP mailbox
SMTP for mailsmtp= "XXX" SMTP mailbox
MAILADDRESS=MAILSMTP ': Address of the outgoing server, such as smtp.163.com
Sender=title ': Sender name
Content=content ': Message content
Fromemail=mailname ': Sender email address
Fromer=title ': Sender name
Username=mailform ': Sender email account number
Password=mailpass ': email password


' What you need to specify
Content=gethttppage ("http://www.jb51.net/")
subject= "title": Message headers
tomail= "XXX": Recipient email Address
Call SendAction (Subject,mailaddress,tomail,sender,content,fromemail,fromer,username,password)

It is OK to set this file to Xxx.vbs and then put it on the database on a regular basis.

If there is anything you don't understand, you can ask MK directly.

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.