ASP email using cdonts

Source: Internet
Author: User
Using the cdonts component to send email from ASP pages.

Using ASP programmers want to now know to do this and with the arrival of IIS4 and the SMTP service of Option Pack 4 it is now fairly easy. there is a component that is made available after the Server Installation of SMTP service. it is called cdonts and it makes sending email rather easy. setting up the SMTP service properly is up to you. it is fairly self explanatory and I have never had any problems installing it. any quality ISP's who offer ASP hosting shoshould already have this set up on their servers.

The following three examples shoshould give you the basic idea and get you started.

Using cdonts to send a text based email message.

<%
Dim mybody

Dim mycdontsmail
%>

<%
Set mycdontsmail = Createobject ("cdonts. newmail ")
Mycdontsmail. From = "somebody@nowhere.com"
Mycdontsmail. To = "nobody@nowhere.com"
Mycdontsmail. Subject = "this is a test"
Mybody = "thank you for ordering that stuff" & vbcrlf
Mybody = mybody & "We appretiate your business" & vbcrlf
Mybody = mybody & "your stuff will arrive within 7 business days"
Mycdontsmail. Body = mybody
Mycdontsmail. Send
Set mycdontsmail = nothing
%>

Using cdonts to send a HTML based email message.

You'll get the general idea .. notice how you have to add extra double quotes inside the HTML. you can use any valid HTML. just make sure you link the images back to your webserver so that the recipient doesn't get a broken image. if the recipient's email program doesn't support HTML this is not always a good way to send email, but most do in my experience and if they don't they will still get the message... it will just look kinda strange.

<%
Dim mycdontsmail2
Dim html
Set mycdontsmail2 = Createobject ("cdonts. newmail ")
Html = "<! Doctype HTML public ""-// IETF // dtd html // en "">"
Html = HTML & "<HTML>"
Html = HTML & "Html = HTML & "<title> sending cdonts email using HTML </title>"
Html = HTML & "Html = HTML & "<body bgcolor =" "ffffff" ">"
Html = HTML & "<p> <font size =" "3" "face =" "Arial" "> <strong>"
Html = HTML & "Name of store </strong> <br>"
Html = HTML & "Incoming customer order </strong> </P>"
Html = HTML & "<p align =" "center" "> bla </P>"
Html = HTML & "</body>"
Html = HTML & "Mycdontsmail2.from = "somebody@somewhere.com"
Mycdontsmail2.to = "nobody@somewhere.com"
Mycdontsmail2.subject = "Incoming customer order"
Mycdontsmail2.bodyformat = 0
Mycdontsmail2.mailformat = 0
Mycdontsmail2.body = html
Mycdontsmail2.send
Set mycdontsmail2 = nothing
%>

Using cdonts to send a file attachment and have a carbon copy recipient.

<%
Dim mybody2
Dim mycdontsmail3
%>

<%
Set mycdontsmail3 = Createobject ("cdonts. newmail ")
Mycdontsmail3.from = "somebody@nowhere.com"
Mycdontsmail3.to = "nobody@nowhere.com"
Mycdontsmail3.cc = "nobody2@nowhere.com"
Mycdontsmail3.subject = "this is a test"


Mycdontsmail3.attachfile server. mappath ("/somedirectory/bla.txt ")
'Or you coshould specify the path exactly if you knew it like below
'Mycdontsmail3. attachfile ("C:/inetpub/wwwroot/somedirectory/bla.txt ")


Mybody2 = "thank you for ordering that stuff" & vbcrlf
Mybody2 = mybody2 & "We appretiate your business" & vbcrlf
Mybody2 = mybody2 & "your stuff will arrive within 7 business days"
Mycdontsmail3.body = mybody2
Mycdontsmail3.send
Set mycdontsmail3 = nothing
%>

when sending an attachment this is just a very simple example. there are certain encoding options and file type settings that you may also want to set.

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.