Microsoft KB Archive/286430

From BetaArchive Wiki
Knowledge Base


How To Send HTML Formatted Mail Using CDO for Windows 2000 and the Local Pickup Directory

Article ID: 286430

Article Last Modified on 2/12/2007



APPLIES TO

  • Microsoft Collaboration Data Objects 2.0
  • Collaboration Data Objects for Exchange 2000



This article was previously published under Q286430

SUMMARY

This article describes how to send HTML formatted mail through the local pickup directory using CDO for Windows 2000 (CDOSYS) or CDO for Exchange 2000 (CDOEX).

MORE INFORMATION

  1. Create a file called Cdopickup.vbs and paste the following code:

    'Send using the Pickup directory on the IIS server.
    Dim iMsg 
    Dim iConf 
    Dim Flds 
    Dim strHTML
    
    Const cdoSendUsingPickup = 1
    
    set iMsg = CreateObject("CDO.Message")
    set iConf = CreateObject("CDO.Configuration")
    
    Set Flds = iConf.Fields
    With Flds 
        .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPickup
        ' TODO: Replace <PICKUP DIRECTORY> with path to your pickup directory
        ' Typically, c:\Inetpub\mailroot\pickup
        .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory")="<PICKUP DIRECTORY>"
        .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>"
    
    Dim iBP
    With iMsg
       Set .Configuration = iConf
       .To = "alias@domain.com"
       .From = "youralias@yourdomain.com"
       .Subject = "This is a test CDOSYS message (Sent via Pickup)"
       .HTMLBody = strHTML
       'TODO: if adding an attachment,
       'uncomment the next line and alter file path as required
       'Set iBP = iMsg.AddAttachment(App.Path & "\file1.txt")
       .Send
    End With
    
     
    ' Clean up variables.
    Set iBP = Nothing
    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.

    This script generates an HTML formatted message and sends it using the pickup directory.


REFERENCES

For additional information, click the article number below to view the article in the Microsoft Knowledge Base:

286431 How To Send HTML Formatted mail Using CDO for Windows 2000 and a Remote SMTP Service


Keywords: kbhowto KB286430