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?


9 Years
Discussion Span
Last Post by shant1976

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
   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
   End With
   set iConf = Nothing
   set iMsg = Nothing
end sub
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.