SMTP settings must be in error

Discussion in 'Classic ASP' started by JeffersonHI, Jun 22, 2008.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. I'm setting up a Send message page using ASP 3.0 - and get an 8004020e error.
    I'm using the following code to set up the message - which errors out on the " .SEND" line near the bottom.
    I got the SMTP config from a previous email in this forum. Can someone assist please?
    <%
    set objMessage = createobject("cdo.message")
    set objConfig = createobject("cdo.configuration")
    Dim ToAddress
    ToAddress= "[email protected]"
    if(Request.Form("email") <>"" and Request.Form("name") <> "" and Request.Form("phone") <>"" and Request.Form("message") <>"") Then
    CcAddress=Request.Form("email")
    ' Setting the SMTP Server
    Set Flds = objConfig.Fields
    Flds.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    Flds.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"
    Flds.update
    ' Debug
    Response.write("Formatting message...")
    Response.write(Request.form("name") &amp; "")
    Response.write(Request.form("phone") &amp; "")
    Response.write(Request.form("email") &amp; "")
    Response.write(Request.form("message") &amp; "")
    Set objMessage.Configuration = objConfig
    With objMessage
    .From = Request.Form("name")
    .To = Request.Form("[email protected]")
    .CC = Request.Form("name")
    .Subject = "Question from "+ Request.Form("name")
    .HTMLBody = Request.Form("message")
    .Send
    End With
     
  2. FYI: I changed "localhost" to "smtp.hrisguy.com" but still receive the same error.
     
  3. Thanks for that reply, Mark. I pasted the code into my program, modified the addresses as needed, and received this error 800402e on the same line, ".SEND." Am I doing something wrong here?


    Here's the code:


    set objMessage = createobject("cdo.message")
    set objConfig = createobject("cdo.configuration")


    ' Setting the SMTP Server
    Set Flds = objConfig.Fields
    Flds.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    Flds.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.hrisguy.com"
    Flds.update



    Set objMessage.Configuration = objConfig
    objMessage.To = "[email protected]"
    objMessage.From = Request.Form("name")
    objMessage.Subject = "Message from "&amp; Request.Form("name")
    objMessage.TextBody = Request.Form("message")
    objMessage.fields.update
    objMessage.Send


    Response.write "Mail sent..."


    set objMessage = nothing
    set objConfig = nothing
     
  4. Hi,
    Two things...
    1. The SMTP server should be left with localhost:
      Flds.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"
    2. While you can place form values like that I'd recommend you create the values first, then place them.
      i.e.
      Dim u_email
      u_email = ucase(trim(request.form("name")))
      then...
      objMessage.From = u_email


    In Classic ASP that works a lot better and allows you to trap values, or debug when things go wrong.
    Also try to use value names that are less generic to avoid problems, "name" as an example is a generic value.
    You would do better to prefix "name", anything, like this for example: f_name
    Salute,
    Mark
     
  5. Mahalo for the reply, Mark. I took your suggestions and all is working fine now.


    Jeff
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page