HOWTO: Send HTML Formatted Mail Over SMTP Using CDONTS

ID: Q189945


The information in this article applies to:
  • Collaboration Data Objects (CDO) for NTS, version 1.2


SUMMARY

This article contains sample code that sends HTML-formatted mail from an Active Server Page (ASP) using CDONTS (Collaboration Data Objects for Microsoft Windows NT Server). You can use this code to programmatically send rich text and graphics embedded in a message.


MORE INFORMATION

Copy the following code into an Active Server Page on an Internet Information Server (IIS) computer that has CDONTS installed:

Sample Code


    <%@ Language=VBScript %>
    <HTML>
    <HEAD>
    <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
    <%

    Dim myMail
    Dim HTML
    Set myMail = CreateObject("CDONTS.NewMail")

    HTML = "<!DOCTYPE HTML PUBLIC""-//IETF//DTD HTML//EN"">"
    HTML = HTML & "<html>"
    HTML = HTML & "<head>"
    HTML = HTML & "<meta http-equiv=""Content-Type"""
    HTML = HTML & "content=""text/html; charset=iso-8859-1"">"
    HTML = HTML & "<meta name=""GENERATOR"""
    HTML = HTML & " content=""Microsoft Visual Studio 6.0"">"
    HTML = HTML & "<title>HTMLMail</title>"
    HTML = HTML & "</head>"
    HTML = HTML & "<body bgcolor=""FFFFFF"">"
    HTML = HTML & "<IMG SRC=""http://www.microsoft.com/library/"
    HTML = HTML & "images/gifs/homepage/microsoft.gif"" BORDER=0 "
    HTML = HTML & "WIDTH=167 HEIGHT=36 ALT=""Microsoft Corporation"">"
    HTML = HTML & "<p><font size =""3"" face=""Arial""><strong>"
    HTML = HTML & "Microsoft Exchange CDONTS Example</strong></p>"
    HTML = HTML & "<p><font size =""2"" face=""Tahoma"">"
    HTML = HTML & "CDO for NTS allows an easy way to send mail.<br>"
    HTML = HTML & "This example shows how the content can be "
    HTML = HTML & "an HTML page<br>"
    HTML = HTML & "which allows you to send rich text and"
    HTML = HTML & "inline graphics.</p>"
    HTML = HTML & "</body>"
    HTML = HTML & "</html>"

    myMail.From="someone@microsoft.com"
    myMail.To="someone@microsoft.com"
    myMail.Subject="Sample CDONTS RTF Message"
    myMail.BodyFormat=0
    myMail.MailFormat=0
    myMail.Body=HTML
    myMail.Send
    set mymail=nothing
    Response.Write "Message Sent"
    %>
    </HEAD>
    <BODY>
    </BODY>
    </HTML> 

Additional query words: kbMsg kbCDONTS kbASP kbVBScript

Keywords : kbhtml kbASP kbMsg kbCDONTS kbGrpMsg
Version : WINDOWS:1.2
Platform : WINDOWS
Issue type : kbhowto


Last Reviewed: January 11, 2000
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.