Partager via


Sending SMTP Mail by the Pickup Directory Using CDOSYS (VBScript)

Topic Last Modified: 2009-07-23

Example

VBScript

'Sending SMTP mail via the pickup directory using CDOSYS

'This ASP page uses CDOSYS to send SMTP mail using the cdoSendUsingPickup option.  The e-mail is created in the pickup directory of the local SMTP server and delivery is handled by the local SMTP service.

<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<%
'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 the CDOSYS configuration fields to use the SMTP service pickup directory
Set Flds = iConf.Fields
With Flds
.Item("https://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPickup
.Item("https://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory") = "c:\inetpub\mailroot\pickup"
.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 settings to the message
With iMsg
Set .Configuration = iConf
.To = "nrnoble@example.com"
.From = "nrnoble@example.com"
.Subject = "This is a test CDOSYS message (Pickup directory)"
.HTMLBody = strHTML
.Send
End With

' cleanup of variables
Set iMsg = Nothing
Set iConf = Nothing
Set Flds = Nothing


%>
<P> </P>

</BODY>
</HTML>