p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

asp_components thread: CDOSYS on Windows 2000


Message #1 by Shaun Steckley <SSTECKLEY@P...> on Mon, 3 Jun 2002 16:59:16 -0400
I am having a problem getting email to work using CDOSYS objects within ASP.
I have paste below the main part of my current code.  No errors are returned
but the email does not send.  If I change the name of the server to
something bogus, an error returns that says "Could not connect to server" so
I would assume the connection is working.  The file is just not getting sent
for some reason.  The code actually works in the testing environment,
however will not send at the clients site.  I was hoping that someone may
know of some common mistakes with the setup of these objects or something
along those lines that they could share with me.

Thanks in advance.
Shaun

      Set objEmail = CreateObject("CDO.Message")
      Set objEmailConfig = CreateObject("CDO.Configuration")
      Set objEmailFields = objEmailConfig.Fields

      objEmailFields(cdoSendUsingMethod) = cdoSendUsingPort   ' 2
      objEmailFields(cdoSMTPServer) = cstr(Application("EmailServerName"))
      objEmailFields(cdoSMTPServerPort) 
clng(Application("EmailServerPort"))
      objEmailFields(cdoSMTPAuthenticate) = cdoAnonymous      ' 0
      objEmailFields.Update

      With objEmail
        Set .Configuration = objEmailConfig

        .To = emailTo
        .From = emailFrom
        .Sender = emailTo
        .Subject = emailSubject
        .TextBody = "" & emailBody & ""

        on error resume next

        .Send
      End With

      set objEmail = nothing
      set objEmailConfig = nothing
      set objEmailFields = nothing

      if (Err.Number <> 0) then
        Response.Write "<p align=""center""><b>There was an unexpected error
when sending the email.</b></p>" & vbcrlf
        Response.Write "<table align=""center"">" & vbcrlf
        Response.Write "  <tr>" & vbcrlf
        Response.Write "    <td><b>Error Number:</b></td>" & vbcrlf
        Response.Write "    <td>" & Err.Number & "</td>" & vbcrlf
        Response.Write "  </tr>" & vbcrlf

        Response.Write "  <tr>" & vbcrlf
        Response.Write "    <td><b>Error Description:</b></td>" & vbcrlf
        Response.Write "    <td>" & Err.Description & "</td>" & vbcrlf
        Response.Write "  </tr>" & vbcrlf
        Response.Write "</table>" & vbcrlf

        Response.End
      end if


********************************************************************
The information contained in this email is confidential and
is intended solely for the use of the person identified and
intended as the recipient. If you are not the intended 
recipient, any disclosure, copying, distribution, or taking of
any action in reliance on the contents is prohibited. If you
receive this message in error, contact the sender
immediately and delete it from your computer.

Personal e-mails are restricted by PSECU policy. As such,
PSECU specifically disclaims any responsibility or liability
for any personal information or opinions of the author
expressed in this email.
********************************************************************


  Return to Index