Use of CDONTS and Jmail in the ASP toolbox of big gray wolf

Source: Internet
Author: User
Tags throw exception
 
CDONTS
<%
Set cdomail = Server. CreateObject ("CDONTS. NewMail") 'to create a mail object
Cdomail. Subject = "Mail Subject" 'Mail title
Cdomail. From = "Sender's Mail" 'Sender's address
Cdomail. To = "Email will from" 'recipient's address
Cdomail. Body = "Mail Body" 'Mail content
Cdomail. Send'
%>
This method is the easiest way to send emails, but it also brings about some problems, that is, few servers will launch this service!
We write programs. Generally, code modularization is required, which facilitates maintenance and migration. Therefore, I will write this email as a child program here, which can be called directly during the call (of course, if you are happy to write it as a function, this is mainly for personal interest):
<%
'Parameter description
'Subject: Mail title
'Mailaddress: the address of the sender server, such as smtp.163.com
'Email: recipient's Email address
'Sender: Sender name
'Content: email Content
'Fromer: the sender's email address
Sub SendAction (subject, mailaddress, email, sender, content, fromer)
Set jmail = Server. CreateObject ("JMAIL. SMTPMail") 'creates a JMAIL object
Jmail. silent = true 'JMAIL does not throw exception errors. The Returned values are FALSE and TRUE.
Jmail. logging = true' enable use log
Jmail. Charset = "GB2312" 'the email text code is Simplified Chinese
Jmail. ContentType = "text/html" 'the email format is HTML
Jmail. ServerAddress = mailaddress 'server on which the email is sent
Jmail. AddRecipient Email 'email recipient
Jmail. SenderName = sender 'email sender's name
Jmail. Sender = fromer 'email address of the Sender
Jmail. Priority = 1' urgent mail program, 1 is the fastest, 5 is the slowest, 3 is the default
Jmail. Subject = subject 'mail title
Jmail. Body = content 'mail content
'The password copy and CC are not used, and the two sentences are blocked here. If you need them, you can recover them here.
'Jmail. AddRecipientBCC Email 'address of the BCC recipient
'Jmail. AddRecipientCC Email 'address of the Email CC recipient
Jmail. Execute () 'Execute the mail to send
Jmail. Close 'Close the email object
End Sub
'Example of calling this Sub
Dim strSubject, strEmail, strMailAdress, strSender, strContent, strFromer
StrSubject = "this is a test email sent using JMAIL"
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.