Sending SMTP Mail by the Pickup Directory Using CDOSYS (Visual Basic)

Topic Last Modified: 2006-06-11

Example

Visual Basic

'Sending SMTP mail via the pickup directory using CDOSYS
'Send using the Pickup directory on the IIS server
    
     
Private Sub sendmsg(strTo As String, strFrom As String)


Dim iMsg As New CDO.Message
Dim iConf As New CDO.Configuration
Dim Flds As ADODB.Fields
Dim strHTML

Set Flds = iConf.Fields
With Flds
.Item(cdoSendUsingMethod) = cdoSendUsingPickup
.Item(cdoSMTPServerPickupDirectory) = "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>"

With iMsg
Set .Configuration = iConf
.To = strTo
.From = strFrom
.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

End Sub