The use of--cdonts and JMail in the ASP toolbox of Big Wolf

Source: Internet
Author: User
Tags format log mail
Jmail|jmail

Cdonts

<%
Set Cdomail = Server.CreateObject ("CDONTS. NewMail ")" Create mail object
Cdomail. Subject = "Mail Subject" ' Message headers
Cdomail. from = "Sender ' s Mail" ' sender's address
Cdomail. to = "Email would from" ' Recipient's address
Cdomail. BODY = contents of mail body
Cdomail. Send ' performs sending
%>

This method of sending mail is the simplest, but also brings a certain problem, that is very few servers will open this service!


We write programs, under normal circumstances are said to code modular, so convenient maintenance, but also easy to transplant. So I'm here to write a subroutine for this email, which can be invoked directly (of course, if you're happy to write a function, this is mainly about personal interest):

<%
' Parameter description
' Subject: Message headers
' MailAddress: Address of the outgoing server, such as smtp.163.com
' Email: Recipient email Address
' Sender: Name of sender
' Content: Message contents
' Fromer: 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 an exception error, returns a value of False to True
Jmail.logging = True ' Enable use of log
JMail. Charset = "GB2312" The code for the message text is Simplified Chinese
jmail. ContentType = "text/html" The format of the message is HTML
JMail. serveraddress = MailAddress ' send mail to server
JMail. AddRecipient Email ' message to the recipient
JMail. SenderName = Sender ' Mail sender's name
JMail. Sender = Fromer ' mail address for the sender of the message
JMail. Priority = 1 ' Mail emergency program, 1 is fastest, 5 is slowest, 3 is the default value
JMail. Subject = Subject ' The title of the message
JMail. The contents of the BODY = Content ' Message
' because there is no use of the secret copy with CC, here to screen out these two sentences, if you need to, you can restore the
' JMail. ADDRECIPIENTBCC Email ' bcc Recipient's address
' JMail. ADDRECIPIENTCC email ' cc's address
JMail. Execute () executes a message to send
JMail. Close ' Closes the mail object
End Sub

' The example of calling this sub
Dim Strsubject,stremail,strmailadress,strsender,strcontent,strfromer
Strsubject = "This is a test message sent with JMail."
Strcontent = "JMail component Send test success!" "
Stremail = "Runbing@eyou.com"
Strfromer = "Runbing@eyou.com"
strmailaddress = "Mail.ubbcn.com"

Call SendAction (Strsubject,strmailaddress,stremail,strsender,strcontent,strfromer)
%>
----------------------------------------------------------

JMail

The

<%
Set jmail = Server.CreateObject ("JMail. SmtpMail ") ' Creates a JMail object
Jmail.silent = True ' JMail does not throw an exception error, returns a value of False to True
Jmail.logging = True ' Enable use of log
JMail. Charset = "GB2312" The code for the message text is Simplified Chinese
jmail. ContentType = "text/html" The format of the message is HTML
JMail. serveraddress = Server address ' sends mail to
JMail. AddRecipient Email ' message to the recipient
JMail. SenderName = "SenderName" ' Mail sender's name
JMail. Sender = "email address" "Mail sender's e-mail addresses
JMail. Priority = 1 ' Mail emergency program, 1 is fastest, 5 is slowest, 3 is the default value
JMail. Subject = "Mail Subject" ' The title of the message
JMail. BODY = content of mail body ' message
JMail. ADDRECIPIENTBCC Email ' bcc recipient's address
JMail. ADDRECIPIENTCC email ' cc's address
JMail. Execute () executes a message to send
JMail. Close ' Closes the mail object
%>

The W3 Jmail4.3 component has redesigned its internal structure--using the Message object instead of the original single object jmail.smtpmail sending mail, and some methods that require authentication (such as 163, Yahoo, etc.) can be resolved in the following ways:
<%
Set JMail = Server.CreateObject ("JMail. Message ")" To create an object to send mail
Jmail.silent = True ' Mask exception error, return False to true two value J
Mail.logging = True ' Enable mail logging
JMail. Charset = "GB2312" ' Text encoding for the message is GB
JMail. ContentType = "text/html" The format of the message is HTML format
JMail. AddRecipient Email ' Address of Mail Recipient
JMail. from = "Email from to Sender" ' E-mail address of sender
JMail. Mailserverusername = "UserName of email" ' User name required to log on to the mail server
JMail. Mailserverpassword = "Password of email" ' Password required to log in to the mail server
JMail. Subject = "Mail Subject" ' Title of Message
JMail. BODY = contents of mail body
JMail. prority = 1 ' Mail emergency program, 1 for fastest, 5 for slowest, 3 for default value
JMail. Send ("server address") ' Perform mail delivery (via mail server addresses)
JMail. Close () ' Closes object
%>




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.