Article ID: 286431 - Last Review: August 25, 2005 - Revision: 3.1
How to send HTML formatted mail using CDO for Windows 2000 and a remote SMTP service
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.
MORE INFORMATION
- 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!" - Edit the sections of the code that are marked "ToDo".
- 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.
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
Note: This article is from Microsoft Knowledage Base
Related problems posted by other users | |
| more... |


