Two Functions of ASP online e-mail (using the jmail and newmail components)

Source: Internet
Author: User

<% 'By Dicky QQ: 25941
Function jmail (send_from, send_to, send_subject, send_body)
'Call the jmail component
'Send email Function
'Metric data:
'Send _ from-sender's mailbox
'Send _ to-receiver mailbox
'Send _ subject-Subject
'Send _ body-response content
Dim jmail
Set jmail = server. Createobject ("jmail. Message ")

Jmail. charset = "gb2312" 'mail character set, "US-ASCII" by default"
'Jmail. isoencodeheaders = false' indicates whether to perform ISO encoding. The default value is true.

'Sender information (assign values using variables)
Jmail. From = send_from 'sender's mailbox
Jmail. fromname = "Administrator" 'sender name
Jmail. Subject = send_subject 'subject

'Authentication
'Jmail. mailserverusername = "user" 'user name for authentication
'Jmail. mailserverpassword = "password" 'password for authentication

'Set the priority, range from 1 to 5. The higher the priority, the higher the 3 is normal.
Jmail. Priority = 3

Jmail. addheader "originating-IP", request. servervariables ("remote_addr ")

'Add one receiver [variable send_from: Recipient address] multiple recipients can be added in the same statement.
Jmail. addrecipient (send_from)
 
'Subject (HTML (note the attachment Link Method in the letter ))
Jmail. htmlbody = ubbcode (send_body)
Jmail. Body = htmldecode (ubbcode (send_body ))

'Send [Call format: objjmail. Send ([Username: password @] smtpserveraddress [: Port])]
'Jmail. Send ("User: password@smtp.21cn.com ")
Sendinfo = jmail. Send (send_to)

'Close and clear the object
Jmail. Close ()
Set jmail = nothing
End Function

Function send_mail (send_from, send_to, send_subject, send_body)
'Call the built-in newmail component in Windows
'Send email Function
'Metric data:
'Send _ from-sender's mailbox
'Send _ to-receiver mailbox
'Send _ subject-Subject
'Send _ body-response content
Dim mailobject
Set mailobject = server. Createobject ("cdonts. newmail ")
Mailobject. bodyformat = 0
Mailobject. mailformat = 0
Mailobject. From = send_from
Mailobject. To = send_to
Mailobject. Subject = send_subject
Mailobject. Body = send_body
Mailobject. Send ()
Set mailobject = nothing

If err then
Response. Write "<script language = JavaScript> alert ('error:" & err. Number & err. Description & "sorry, an error occurred while sending the email! :( '); </SCRIPT>"
Else
Response. Write "<script language = JavaScript> alert ('Congratulations, the email is sent successfully! __^ '); </SCRIPT>"
End if
End function %>

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.