Solved

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

Posted on 2008-06-18
6
4,351 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

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…
Lync server 2013 Backup Service Error ID 4049 – After File Share Migration
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

757 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

22 Experts available now in Live!

Get 1:1 Help Now