質問

I am currently in the process of updating many test sites on an old server so that they won't break when the old server gets discontinued in the next couple months. The contact form for one site in particular is already broken. When a user clicks on submit after filling in their information, they are presented with this error:

Server object error 'ASP 0177 : 800401f3'

Server.CreateObject Failed

/contactsubmit.asp, line 79

800401f3


Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.FromName = "Web Visitor"
If request("email") <> "" then
  Mailer.replyto = request("email")
Else
  Mailer.replyto = "noEmailEntered@domain.com"
End If
Mailer.FromAddress = "my@email.com"
Mailer.RemoteHost = "hostserver"
If TempTest = TRUE then
Else
  Mailer.AddRecipient siteOwner, ContactEmail
  If ContactCC <> "" then
    Mailer.AddCC siteOwner, ContactCC
  End If
End If
If DesignerEmail <> "" then
    Mailer.AddBCC DesignerEmail, DesignerEmail
End If
Mailer.Subject = siteOwner & " Contact Form"
Mailer.ContentType = "text/html"
Mailer.BodyText = strBody
If Mailer.SendMail then
  response.redirect "contact.asp?sent=yes"
Else
  response.redirect "contact.asp?sent=no"
End If

I was told that SMTP isn't the way that emails need to get sent anymore so I tried changing it all to CDOSYS. But the funny thing is, there are a lot more sites on this server that I have tested using the same SMTP code that work. Changes using CDOSYS:

Set Mailer = Server.CreateObject("CDO.Message")
Mailer.From = "Web Visitor <my@email.com>"
If request("email") <> "" then
  Mailer.ReplyTo = request("email")
Else
  Mailer.ReplyTo = "noEmailEntered@domain.com"
End If
Mailer.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "hostserver"
If TempTest = TRUE then
Else
  Mailer.AddRecipient siteOwner, ContactEmail
  If ContactCC <> "" then
    Mailer.Cc siteOwner, ContactCC
  End If
End If
If DesignerEmail <> "" then
    Mailer.Bcc DesignerEmail, DesignerEmail
End If
Mailer.Subject = siteOwner & " Contact Form"
Mailer.HTMLBody = strBody
If Mailer.Send then
  response.redirect "contact.asp?sent=yes"
Else
  response.redirect "contact.asp?sent=no"
End If

But now I get this error:

Microsoft VBScript runtime error '800a01b6'

Object doesn't support this property or method: 'Mailer.AddRecipient'

/contactsubmit.asp, line 89

I have tried changing it to Mailer.Add and to Mailer.AddAddress with no luck. Does anyone know how I can get around this error and hopefully get this to work? I've never worked with mail servers before so I apologize if this is an easy fix, but I've searched for the past 3 hours and can't come up with a good alternative to .AddRecipient.

役に立ちましたか?

解決

Try to execute the below simplest way of sending mail using CDO and then take the relevant fields from it and apply to your script:

Set myMail=CreateObject("CDO.Message")
myMail.Subject="Sending email with CDO"
myMail.From="mymail@mydomain.com"
myMail.To="someone@somedomain.com"
myMail.TextBody="This is a message."
myMail.Send
set myMail=nothing

As you can see the way to add recipient is like this:

myMail.To="someone@somedomain.com"

You can see more examples here

Hope this helps.

他のヒント

The CDO.Message object simply has the string properties of To, Cc and Bcc to which you assign a standard semi-colon delimited list of smtp email addresses for example:
"Joe Bloggs" <joeB@somecompany.com>; "Fred Smith" <fSmith@smiths.co.uk>

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top