Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2008-06-18
6
Medium Priority
?
4,685 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

Independent Software Vendors: 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!

Question has a verified solution.

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

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
A phishing scam that claims a recipient’s credit card details have been “suspended” is the latest trend in spoof emails.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

618 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