Use the CDO component to send emails

Source: Internet
Author: User

Let's play with the mail function. Of course, we cannot send emails to Perl or PHP! We still need to use components. However, you do not need to spend any money on this component! It is self-contained in SMTP in IIS! Let's use the email sending function for a flash!

Set CDO = server. Createobject ("cdonts. newmail ")
CDO. Send "webmaster@aspcn.com", "dd@263.net", "ASP Chinese network Letter", "Hello! ", 0
Set CDO = nothing

!!!!??? That's short !!! Impossible!

Hey hey, you try. If you have a server, change the dd@263.net to your email, and then put thisCodeGet the above and try it. You will be able to receive the letter!

This is the most direct method for sending emails! Format:

CDO. Send fromaddress, toaddress, subject, body, importance

Of course, we can make it more complex. Let's take a look and write the above example into detail!

Set CDO = server. Createobject ("cdonts. newmail ")
CDO. From = "webmaster@aspcn.com"
CDO. To = "dd@263.net"
CDO. Subject = "ASP Chinese net letter"
CDO. Body = "Hello! "
CDO. mailformat = 0
CDO. bodyformat = 0
CDO. Importance = 0
CDO. Send
Set CDO = nothing
 

So everyone can see it clearly!

Here are some explanations!

Importance indicates the importance of an email. 0 indicates low importance, 1 indicates normal, and 2 indicates high importance.

Bodyformat refers to the body format of an email. 0 indicates the HTML format, and 1 indicates the plain text.

Mailformat refers to the Message format, text message (1), or MIME format (0)

We can add attachments to emails with only one sentence:

CDO. attachfile "C:/du/asp.gif"

Easy!

All right, there are so many emails. You can try to send your first mail from ASP!

 

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.