Solved

large email message. sometimes get server error, other times - dont

Posted on 2006-11-27
17
400 Views
Last Modified: 2009-12-16
hello,

I have built a very large email form... now when I send identical form information sometimes it works.....

 other times i get this error

error '80040211'
/apply_mail.asp, line 30

or this error

CDO.Message.1 error '80040213' The transport failed to connect to the server.

why does it work 50% of the time, the other times i get this error?
0
Comment
Question by:jblayney
  • 9
  • 8
17 Comments
 
LVL 22

Expert Comment

by:WMIF
Comment Utility
is this going to an internal server or external server?
0
 
LVL 1

Author Comment

by:jblayney
Comment Utility
external, an asp web form externally hosted.
0
 
LVL 22

Expert Comment

by:WMIF
Comment Utility
im sorry, i meant to ask if the form was being submitted to an external or internal smtp server.  are you using the webserver's smtp server or are you pointing to another server for delivery?
0
 
LVL 1

Author Comment

by:jblayney
Comment Utility
Im not exactly sure, I think I am using the servers smtp... here is a bit of the code


<!--METADATA TYPE="typelib" UUID="CD000000-8B95-11D1-82DB-00C04FB1625D" NAME="CDO for Windows Library" -->

<!--METADATA TYPE="typelib" UUID="00000205-0000-0010-8000-00AA006D2EA4" NAME="ADODB Type Library" -->
<%
SUB sendmail( fromWho, toWho, Subject, Body )
Dim objCDO
Dim iConf
Dim Flds

Const cdoSendUsingPort = 2

Set objCDO = Server.CreateObject("CDO.Message")
Set iConf = Server.CreateObject("CDO.Configuration")

Set Flds = iConf.Fields
With Flds
            .Item(cdoSendUsingMethod) = cdoSendUsingPort
            .Item(cdoSMTPServer) = "mail-fwd"
            .Item(cdoSMTPServerPort) = 25
            .Item(cdoSMTPconnectiontimeout) = 10
            .Update
End With

Set objCDO.Configuration = iConf

objCDO.From = fromWho
objCDO.To = toWho
objCDO.Subject = Subject
objCDO.TextBody = Body
objCDO.Send

Dim ...( about 70 fields)


firstName_req = Trim(Server.HTMLEncode(Request.form("firstName_req")))
lastName_req = Trim(Server.HTMLEncode(Request.form("lastName_req")))
grade_req_numeric = Trim(Server.HTMLEncode(Request.form("grade_req_numeric")))
address_req = Trim(Server.HTMLEncode(Request.form("address_req")))
city_req = Trim(Server.HTMLEncode(Request.form("city_req")))
state_req = Trim(Server.HTMLEncode(Request.form("state_req")))
zipcode = Trim(Server.HTMLEncode(Request.form("zipcode")))
country_req = Trim(Server.HTMLEncode(Request.form("country_req")))
(about 60 more)


END SUB



fromWho = Trim(Server.HTMLEncode(Request.form("email_email")))
toWho = "me@mywebsite.net"
Subject = "******** Online Application ********"

Body = " ******** Online Application ********" &_
                  vbcrlf & vbcrlf &_
                         
                          "first name: " & Trim(Server.HTMLEncode(Request.form("firstName_req")))  &_
                          vbcrlf &_
                  "last name: " & Trim(Server.HTMLEncode(Request.form("lastName_req")))  &_
                          vbcrlf &_
                          "grade: " & Trim(Server.HTMLEncode(Request.form("grade_req_numeric")))  &_
                          vbcrlf &_
                          "Address: " & Trim(Server.HTMLEncode(Request.form("address_req")))  &_
                           vbcrlf &_
                         

 (about 70 fields are sent in this email body)                                                                                                        
                          date


If toWho <> "" THEN
sendMail fromWho, toWho, Subject, Body


'Cleanup
Set ObjCDO = Nothing
Set iConf = Nothing
Set Flds = Nothing
' Response.redirect "tech-support-cdo-form.asp"
' Any existing page can be used for the response redirect method
END IF
%>




0
 
LVL 22

Expert Comment

by:WMIF
Comment Utility
>>.Item(cdoSMTPServer) = "mail-fwd"

this is the server that you are using to do the delivery.  is that the local server or another one?
0
 
LVL 1

Author Comment

by:jblayney
Comment Utility
i assume local
0
 
LVL 1

Author Comment

by:jblayney
Comment Utility
to clarify, i am not the system administrator, I have no idea how they run their servers. I just wrote the asp code...

I dont send the form to another server to process, it happens on the server the code is on
0
 
LVL 22

Expert Comment

by:WMIF
Comment Utility
im thinking that the smtp server is busy while you are trying to connect.  is this a shared server?  have you contacted the system administrator to find out if they are having any issues?
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 1

Author Comment

by:jblayney
Comment Utility
yes, it is a shared server...  My initial thought was that it was a server RAM issue.
0
 
LVL 22

Expert Comment

by:WMIF
Comment Utility
it could be ram, but it could also just be that another site on that server is sending a lot of emails as well.  try contacting the sys admin.
0
 
LVL 1

Author Comment

by:jblayney
Comment Utility
Hello,

Ok, to change this a bit, how can I validate this code so that if the email fails or it doens't connect to server that the user gets my error message instead of the default server message

i tried this at the bottom but it doesnt work

If objCDO.Send <> "" then
response.write "We are having Technical Difficulties, please try again later or give us a call"
end if

(sorry if this seems noobish, i have been using php for years now and forgot all my asp)
0
 
LVL 22

Expert Comment

by:WMIF
Comment Utility
dont worry about being noobish.  thats what we are here for. :)

i would do some error trapping like this:

on error resume next      'basically ignores errors and moves onto the next line
objCDO.Send
if err.number <> 0 then    'check the error object to see if any were raised.  0 indicates no error
  'we got an error.  do what you wish
end if
on error goto 0      'negate the "resume next" line to go back into the normal error handling.
0
 
LVL 1

Author Comment

by:jblayney
Comment Utility
Hello,


Thanks for the help, my error handling is a bit off... I get both messages, see my code below... also, I found out the issue is not my code, it is my macintosh/safari, when I send the form on a pc, I get no errors, i was able to send 27 in a row on a pc :(

on error resume next      'basically ignores errors and moves onto the next line
objCDO.Send
if err.number <> 0 then    'check the error object to see if any were raised.  0 indicates no error
response.write "<p align='center'><font color='#000000' size='2' face='Arial, Helvetica, sans-serif'><br><br>Thank you for your interest in ACA,<br><br>We will contact you during the next business day<br><br>If you would like to apply again for someone else<br><br>Please click <a href='apply.htm' target='_self'>here</a></font></p>"
end if

if err.number > 0 then    'check the error object to see if any were raised.  0 indicates no error
response.write "<p align='center'><font color='#000000' size='2' face='Arial, Helvetica, sans-serif'><br><br>We are having Technical Difficulties, please try again later or give us a call</font></p>"
end if
0
 
LVL 22

Accepted Solution

by:
WMIF earned 50 total points
Comment Utility
>>if err.number <> 0 then
>>if err.number > 0 then

both of those if statements will run if the error number is not zero.  you need to use an if with an else statement to handle this.

if err.number <> 0 then    'check the error object to see if any were raised.  0 indicates no error
  response.write "<p align='center'><font color='#000000' size='2' face='Arial, Helvetica, sans-serif'><br><br>We are having Technical Difficulties, please try again later or give us a call</font></p>"
else
  response.write "<p align='center'><font color='#000000' size='2' face='Arial, Helvetica, sans-serif'><br><br>Thank you for your interest in ACA,<br><br>We will contact you during the next business day<br><br>If you would like to apply again for someone else<br><br>Please click <a href='apply.htm' target='_self'>here</a></font></p>"
end if
0
 
LVL 22

Expert Comment

by:WMIF
Comment Utility
>>also, I found out the issue is not my code, it is my macintosh/safari, when I send the form on a pc, I get no errors,

this is very strange because the client's browser should not affect anything that the server does.  the client is only submitting information to the server.  did you try running the mac and pc at the same time?
0
 
LVL 1

Author Comment

by:jblayney
Comment Utility
"this is very strange because the client's browser should not affect anything that the server does.  the client is only submitting information to the server.  did you try running the mac and pc at the same time?"

I know this is strange... Since I bought my new mac, I have noticed on a few asp websites I built that I get this problem... Im not sure what to say, it is just my conclusion from the evidence...

as a matter of fact when we were testing it yesterday (myself and someone on a pc) we were doing it at the same time... he sent 27 in a row and i get errors 3 out of 4 times....

If I switch to IE on my mac, I dont get the errors anymore

justin
0
 
LVL 22

Expert Comment

by:WMIF
Comment Utility
that might be a question to ask in the mac topic area to see if anyone else has had problems like this.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
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: …

772 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

10 Experts available now in Live!

Get 1:1 Help Now