Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 507
  • Last Modified:

Problem sending email through a .ASP program

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=""http://www.ardmorerotary.org/"" target=""_blank"">http://www.ardmorerotary.org</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
1 Solution
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.
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?
Samer ChidiacChief Innovation & Strategy OfficerCommented:
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/ASP.net
dyaroshAuthor Commented:
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.
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now