Problem sending email through a .ASP program

Posted on 2005-04-19
Last Modified: 2013-11-30
I ported a website from one webhost provider to another and now the email function on the site is not working.  The email function sends out an email to everyone on the list chosen by the user.  I've included a copy of the code that I'm using.  I'm getting the following error when the .Send is issued:

error '8004020e'


Line 60 is the .Send line.

If anyone can help me I would greatly appreciate it.

function sendArrayEmail(arrRecips, strSubject, strMessage, strSenderName, strSenderEmail)
      Dim mailObj, mailBreak, mailTo, sch, cdoConfig
      mailBreak = chr(13) & chr(10) & "<br>"
      strMsg = Replace(strMessage, chr(13), mailBreak)

      Set cdoConfig = Server.CreateObject("CDO.Configuration")
      With cdoConfig.Fields
            .Item(sch & "sendusing")=2      ' cdoSendUsingPort
            .Item(sch & "smtpserver")=""
      End With
      Set mailObj = Server.CreateObject("CDO.Message")
'      mailObj.RemoteHost = "mail-fwd"
'      mailobj.FromName = strSenderName
'      mailobj.FromAddress = strSenderEmail
'      mailObj.ContentType = "text/html"
'      Set mailObj = Server.CreateObject("CDONTS.NewMail")

      Set mailObj.Configuration = cdoConfig
      mailobj.From = strSenderName
      strBody = strMsg & mailBreak & mailBreak
      strBody = strBody & "This message was sent from the Ardmore Rotary Website on " & FormatDateTime(Now(), vbLongDate) & " by " & strSenderName & "." & mailBreak& mailBreak
      strBody = strBody & "<a href=""mailto:" & strSenderEmail & """>" & strSenderEmail & "</a>" & mailBreak & mailBreak
      strBody = strBody & "<a href="""" target=""_blank""></a>"
      mailobj.Subject = strSubject
      mailobj.TextBody = strBody
'      mailobj.BodyText = strBody
      arrSent = arrRecips
      mailTo = ""
      For i =0 to uBound(arrRecips,2)      
            If arrRecips(3,i) = True Then
                  intEmail = 1
                  intEmail = 2
            End If
            strEmail = arrRecips(intEmail,i)

            If strEmail <> "" Then
'                  mailObj.AddRecipient arrRecips(0,i), strEmail
                  mailTo = mailTo & strEmail & ";"
                  arrSent(0, i) = arrRecips(0,i)
                  arrSent(1, i) = strEmail
            End If                  

'      mailObj.SendMail
      mailObj.To = strEmail
      set mailObj = nothing
      set cdoConfig = nothing
      sendArrayEmail = arrSent
End function
Question by:dyarosh
    LVL 1

    Expert Comment

    Is your new web host configured to allow you to use CDO to relay mail through their webserver?  They must have the smtp component configured to allow relay for web applications.  They may be using a component for web app mail rather than allowing CDO.  Check their documentation for form to email.
    LVL 16

    Expert Comment

    Yes, lots of hosts dont allow CDO in favour of other mail applications or none at all.

    It could also be that they block SMTP being used from any other mail server than their own. This is to make people responsible for spam if they send it.

    So 2 thing to ask your new host. 1) Do you support CDO? 2) Is there a specific mailserver I have to use to send mail?
    LVL 6

    Expert Comment

    by:Samer Chidiac
    if your host is using Windows 2003 .. then the CDO is required when using ASP .. other wise you can use Cdont Mail component ...

    but also check your Host with that .. your code looks Fine .. ( i didn't go in depth with it - but it seems ok )



    Samer Chidiac
    Microsoft MVP - ASP/

    Author Comment

    I modified the code to use the CDONTS Mail Component and this is the error I receive:

    Microsoft VBScript runtime error '800a0046'

    Permission denied


    Line 61 is the .Send function.  I don't know what permission it is denying me.  If anyone has any idea please let me know.  I'm getting very frustrated with this problem.
    LVL 16

    Accepted Solution

    Do as I say in my first post. Ask your host what email they allow and which (if any) SMTP server the mail must go through.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Suggested Solutions

    Let’s list some of the technologies that enable smooth teleworking. 
    Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
    Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
    The viewer will learn how to dynamically set the form action using jQuery.

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now