I am trying to send an email using CDOSYS with classic ASP. But I am getting this error:

CDO.Message.1 error '80040220'

The "SendUsing" configuration value is invalid.

/send.asp, line 8

line1     <%
line2     Dim myMail
line3     Set myMail=CreateObject("CDO.Message")
line4     myMail.Subject="Sending email with CDO"
line5     myMail.From="from@domain.com"
line6     myMail.To="to@domain.com"
line7     myMail.TextBody="This is a message."
line8     myMail.Send
line9     set myMail=nothing
line10    %>

Can anyone plz help?

Thanx

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
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.