Try the following code from my AspLib-library of general asp-classes
and asp-functions:
sub SendMail( byval psTo, byval psSubject , byval psBody )
'______________________________________________________________________________
'
' 'Send Mail'
'______________________________________________________________________________}
Dim iMsg
Dim iConf,Flds
if psTo = "" then Exit sub
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
With Flds
' assume constants are defined within script file
.Item("[url]http://schemas.microsoft.com/cdo/configuration/sendusing[/url]") = 2
.Item("[url]http://schemas.microsoft.com/cdo/configuration/smtpserver[/url]") = <your relay server>
.Item("[url]http://schemas.microsoft.com/cdo/configuration/smtpserverport[/url]") = 25
.Update
End With
With iMsg
Set .Configuration = iConf
.To = psTo
.From = "{#EmailContact}"
.Subject = psSubject
.ReplyTo = "{#EmailContact}"
.BCC = "" ' "{#EmailContact}"
'.Importance = cdoNormal
'For body text use either one of below
'.TextBody = ''
.HTMLBody= psBody
'.CreateMHTMLBody "[url]http://www.w3schools.com/asp/[/url]"
'.CreateMHTMLBody "[url]file://c:/mydocuments/test.htm[/url]
'.AddAttachment "c:\mydocuments\test.txt"
' .MailFormat = 0 ' 0 for html - 1 for plain text
' .BodyFormat = 0 ' 0 for html - 1 for plain text
.Send
End With
set iConf = Nothing
set iMsg = Nothing
end sub