Help and Support
 

powered byLive Search

How to send HTML formatted mail using CDO for Windows 2000 and a remote SMTP service

Article ID:286431
Last Review:August 25, 2005
Revision:3.1
This article was previously published under Q286431

SUMMARY

This article describes how to send HTML formatted mail using CDO for Windows 2000 (CDOSYS) or CDO for Exchange 2000 (CDOEX) using a remote computer's SMTP service.

Back to the top

MORE INFORMATION

1. Create a file called Cdosmtp.vbs and paste the following code:
' Send by connecting to port 25 of the SMTP server.
Dim iMsg 
Dim iConf 
Dim Flds 
Dim strHTML

Const cdoSendUsingPort = 2

set iMsg = CreateObject("CDO.Message")
set iConf = CreateObject("CDO.Configuration")

Set Flds = iConf.Fields

' Set the CDOSYS configuration fields to use port 25 on the SMTP server.

With Flds
    .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
    'ToDo: Enter name or IP address of remote SMTP server.
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "<remote SMTP server>" 
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10  
    .Update
End With

' Build HTML for message body.
strHTML = "<HTML>"
strHTML = strHTML & "<HEAD>"
strHTML = strHTML & "<BODY>"
strHTML = strHTML & "<b> This is the test HTML message body</b></br>"
strHTML = strHTML & "</BODY>"
strHTML = strHTML & "</HTML>"

' Apply the settings to the message.
With iMsg
    Set .Configuration = iConf
    .To = "<email address>" 'ToDo: Enter a valid email address.
    .From = "<email address>" 'ToDo: Enter a valid email address.
    .Subject = "This is a test CDOSYS message (Sent via Port 25)"
    .HTMLBody = strHTML
    .Send
End With

' Clean up variables.
Set iMsg = Nothing
Set iConf = Nothing
Set Flds = Nothing

MsgBox "Mail Sent!"
					
2. Edit the sections of the code that are marked "ToDo".
3.Save the file, and then double-click it.

The code creates an HTML-formatted message and sends it using the remote computer's SMTP service.

Back to the top

REFERENCES

For additional information, click the article number below to view the article in the Microsoft Knowledge Base:
286430 (http://support.microsoft.com/kb/286430/EN-US/) How To Send HTML Formatted mail Using CDO for Windows 2000 and the Local Pickup Directory

Back to the top


APPLIES TO
Microsoft Collaboration Data Objects 2.0
Collaboration Data Objects for Exchange 2000

Back to the top

Keywords: 
kbhowto KB286431

Back to the top

Article Translations

 

Other Support Options

  • Need More Help?
    Contact a Support professional by Email, Online or Phone.
  • Customer Service
    For non-technical assistance with product purchases, subscriptions, online services, events, training courses, corporate sales, piracy issues, and more.
  • Newsgroups
    Pose a question to other users. Discussion groups and Forums about specific Microsoft products, technologies, and services.