Solved

error '80040211' when trying to use the CDO Mailer in ASP.

Posted on 2008-06-18
6
4,414 Views
Last Modified: 2013-02-06
I am using the below code, that I got from my hosting services (Aplus) web site, but I am getting the error denoted below. Can you please help me get this working? I'm probably doing something wrong.

I have this code all in one asp page named myasp.asp. Is that the correct way to do it? Soemthing makes me think I should have two files - can an ASP page post to itself?

All I am trying to to is have a form on my web site where a person will provide their email address and maybe some other info, click Submit, and have the page automatically send them an emai with a link. I think I have the right code here to do this but can't get it to work. I know the email addresses specifified in the code are not real, but I have real addresses in them on my page.


HERE IS THE ERROR I GET WHEN I HIT THE SUBMIT BUTTON
"error '80040211'  /myasp.asp, line 77 objMessage.Send"
FYI:  Line 77 is the line that contain this: "objMessage.Send"


HERE IS THE CODE I AM USING
<!-------------begin form------------>
<%
Dim strFrom, strSubject, strBody 'Strings for fromaddress, subject, body
Dim objCDOMail 'The CDO object

sch = "http://schemas.microsoft.com/cdo/configuration/"
Set cdoConfig = CreateObject("CDO.Configuration")

With cdoConfig.Fields
      'cdoSendUsingPort
      .Item(sch & "sendusing") = 2

      'Email Server
      .Item(sch & "smtpserver") = "pro44.abac.com"

      'Basic authentication
      .Item(sch & "smtpauthenticate") = 1

      'Type your email account below
      .Item(sch & "sendusername") = "email@somewhere.com"

      'Type your email password below
      .Item(sch & "sendpassword") = "xxxxx"

      .Item(sch & "smtpserverport") = 465
      
      'SSL connection enabled
      .Item(sch & "smtpusessl") = true
      .update
End With


'First we'll read in the values entered
strFrom = Request.Form("from")

'These would read the message subject and body if we let you enter it
strSubject = Request.Form("subject")
strBody = Request.Form("body")

' Some spacing
strBody = strBody & vbCrLf & vbCrLf

' Initiate Is email valid sub function
If strFrom = "" Or Not IsValidEmail(strFrom) Then

' Create Form
%>
<FORM ACTION="myasp.asp" METHOD="post">
Enter your e-mail address:<BR>
<INPUT TYPE="text" NAME="from" SIZE="30"></INPUT><BR><BR>

Subject:<BR>
<INPUT TYPE="text" NAME="subject" SIZE="30"></INPUT><BR><BR>

Message:<BR>
<TEXTAREA NAME="body" ROWS="10" COLS="40" WRAP="virtual"></TEXTAREA><BR>

<INPUT TYPE="submit" VALUE="Send Mail"></INPUT>
</FORM>
<%
Else
' Create an instance of the NewMail object.
Set objMessage = Server.CreateObject("CDO.Message")
Set objMessage.Configuration = cdoConfig

' Set the properties of the object
objMessage.From = strFrom
objMessage.To = "email@somewhere.com" 'The recipient of the form data
objMessage.Subject = strSubject
objMessage.TextBody = strBody

' Some useful extra variables
'objMessage.Cc = "" 
'objMessage.Bcc = "" 

' Send the message!
objMessage.Send

' Set the object to nothing because it immediately becomes
' invalid after calling the Send method.
Set objMessage = Nothing

' Set your Response after the Send Mail button is pushed.
Response.Write "Your Message was sent!"

End if
' End page logic
%>

<% ' Only functions and subs follow!

' A quick email syntax checker.
Function IsValidEmail(strEmail)
 Dim bIsValid
 bIsValid = True

 If Len(strEmail) < 5 Then
  bIsValid = False
 Else
  If Instr(1, strEmail, " ") <> 0 Then
   bIsValid = False
  Else
   If InStr(1, strEmail, "@", 1) < 2 Then
    bIsValid = False
   Else
    If InStrRev(strEmail, ".") < InStr(1, strEmail, "@", 1) + 2 Then
     bIsValid = False
    End If
   End If
  End If
 End If

 IsValidEmail = bIsValid
End Function
%>
<!-------------end form------------>



0
Comment
Question by:JA67
  • 3
  • 2
6 Comments
 
LVL 15

Expert Comment

by:dosth
ID: 21819599
0
 

Author Comment

by:JA67
ID: 21821729

Thanks for your response. This is something that would have to be checked on the web server right, not my PC? I don't believe I have access to mess with the web server in this way. Sorry, I'm pretty ignorant about this.

Thanks,
JA67
0
 
LVL 15

Accepted Solution

by:
dosth earned 500 total points
ID: 21821758
yes, this is webserver, you can just ask your host to check is port 25 is open and tell email is not realying

Thanks
Dosth
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:JA67
ID: 21821919
Thank you. I called Aplus and was told that port 25 is closed on the web server that I am using. Stink! He said that there are usually 7 - 8 or so sites on each server and they usually keep these ports, like 25, closed unless you have a dedicated server. What a crock! He said I could put a ticket in and request the port be opened, but I don't see why they would do it just for me. I will ask anyway and see what happens.

Thanks!

JA6
0
 
LVL 15

Expert Comment

by:dosth
ID: 21822004
thanks
0
 

Expert Comment

by:LynneV
ID: 38859654
Just in case anyone else runs across this error while trying to move an asp classic site to an IIS 7 or IIS 7.5 system - the authenticated email has to be in the format name@provider.com. I had two clients with authentication email addresses in the format mail.some.some or somebunchofletters and it wouldn't work in CDO until I had them setup a 'normal' address. It took 3 days to find... so if it helps you, great.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

First of all, clustering IIS is something you should rarely consider doing. In almost all cases, Microsoft Network Load Balancing (NLB) (http://technet.microsoft.com/en-us/library/cc758834(WS.10).aspx) is a much better solution when you need to p…
Running classic asp applications under Windows Server 2008 R2 (x64) and IIS 7 is not as easy as one may think. It took me a while to figure it out while getting error 8002801d a few times. After you install the OS you will need to install the fol…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

828 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