473,327 Members | 1,896 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

smtp .send() causing bottleneck

My asp script used to be able to send email to an unlimited amount of users.
But a couple weeks ago I started getting this error message "transport failed to connect to server". So I increased the smtp connection timeout.
Then I started getting an error saying the maximum amount of time for my script to run had been reached. So I increased Sever.ScriptTimeout.
Now I'm just getting a generic error message saying my page cannot be displayed.
All my script does is send email to a list of users. The list of users is gotten from a database. After all the emails are sent then I display a table the shows which users were emailed. If I comment out my call to .Send(), then the page that shows the list of users displays just fine. So I know the problem isn't with getting a list of users nor is it connecting to the database.
However, if my user list is only 12 users long then the emails are sent out fine. It takes a while but everything works great. If the user list is more than 12 users then that's when I get the "cannot display page" error.
Below is a snippet of my code that actually sends out the emails:
Expand|Select|Wrap|Line Numbers
  1.  
  2.         Dim Newmail, iConf, Flds
  3.     Set Newmail = Server.CreateObject ("cdo.message")
  4.     Set iConf = Server.CreateObject("cdo.Configuration")
  5.     Set Flds = iConf.Fields
  6.  
  7.     With Flds
  8.         .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2            
  9.         .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "11.11.111.1"
  10.         .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
  11.         .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 30
  12.         .Update
  13.     End With
  14.  
  15.     With Newmail
  16.         Set .Configuration = iConf
  17.         .To = email_to
  18.         .From = email_from
  19.         .Subject = email_subject
  20.         .HTMLBody = email_body
  21.         .Send()
  22.     End With
  23.  
  24.     Set Newmail = Nothing
  25.     Set Flds = Nothing
  26.     Set iConf = Nothing
  27.  
I'd appreciate any thoughts or ideas as to why the ability of my script to send email has been curtailed.

Thanks!
Jennifer
Dec 30 '08 #1
2 2099
CroCrew
564 Expert 512MB
Hello jcrum00,

Try wrapping your mailing function within a “function” that way you only send out one email out at a time. This way all you have to do is pass the recipient’s email address into the function during the looping of your database records. Also you can add in error checking at that point too.

Without seeing all your code to provide a complete fit; here is an example:

Expand|Select|Wrap|Line Numbers
  1. Set objConn = Server.CreateObject("ADODB.Connection")
  2. objConn.Open Application("DataBaseConnectionString")
  3.  
  4. Set objMyData = objConn.Execute("SELECT * FROM MyTable") 
  5.  
  6. Function SendMyMail(xTo)
  7.     Dim Newmail, iConf, Flds 
  8.     Set Newmail = Server.CreateObject ("cdo.message") 
  9.     Set iConf = Server.CreateObject("cdo.Configuration") 
  10.     Set Flds = iConf.Fields 
  11.  
  12.     With Flds 
  13.         .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2             
  14.         .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "11.11.111.1" 
  15.         .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 
  16.         .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 30 
  17.         .Update 
  18.     End With 
  19.  
  20.     With Newmail 
  21.         Set .Configuration = iConf 
  22.         .To = xTo 
  23.         .From = email_from 
  24.         .Subject = email_subject 
  25.         .HTMLBody = email_body 
  26.         On Error Resume Next 
  27.             .Send() 
  28.         If Err <> 0 Then  
  29.             Response.Write("Error Sending To: " & xTo & " [" & Err.Description & "]") 
  30.         Else
  31.             Response.Write("Mail Sent To: " & xTo) 
  32.         End If 
  33.     End With 
  34.  
  35.     Set Newmail = Nothing 
  36.     Set Flds = Nothing 
  37.     Set iConf = Nothing 
  38. End Function 
  39.  
  40. <html>
  41.     <head>
  42.         <title>Example</title>
  43.     </head>
  44.     <body>
  45.         <table>
  46.             <%Do Until (objMyData.EOF)%>
  47.                 <tr>
  48.                     <td><%SendMyMail(objMyData("RecipientEmail"))%></td>
  49.                 </tr>
  50.                 <%objMyData.MoveNext%>
  51.             <%Loop%>
  52.         </table>
  53.     </body>
  54. </html>    
  55.  
Hope this helps,
CroCrew~
Dec 30 '08 #2
Thanks CroCrew! I actually do have my mailing function wrapped within another function and am sending out emails one at a time.
My code was working fine but then all of a sudden I started having problems. I'm wondering if there is some sort of microsoft patch or something that could have affected either the smtp server or my web server.
Dec 30 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Andy Turner | last post by:
Hi, I'm trying to setup PHP so it will use a remote SMTP server. I'm going to sound like a newbie but how? I know you need to alter php.ini, change SMTP from localhost to the SMTP server and the...
21
by: Nancy | last post by:
Hi, Guys, Is there any other way to use python or mod_python writing a web page? I mean, not use "form.py/email", no SMTP server. <form action="form.py/email" method="POST"> ... Thanks a lot. ...
15
by: Steven Burn | last post by:
My server has POP but only has SMTP if sending to my domain, and not other domains (such as hotmail). I'm therefore wondering, if anyone knows of any scripts etc, that will allow me to have a sort...
1
by: bivin | last post by:
hai i am requesting your technical support. please help me. i have been working with this for five days. the problem is relating with the smtp. i am trying to send an email from the asp.net...
0
by: Dan Sikorsky | last post by:
This is a C# console app using SMTP to send an email. The .EML file stays in the Queue folder because I close down the Internet Connection prematurely. What's the best way to keep the Internet...
34
by: antonyliu2002 | last post by:
I've set up the virtual smtp server on my IIS 5.1 like so: 1. Assign IP address to "All Unassigned", and listen to port 25. 2. Access Connection granted to "127.0.0.1". 3. Relay only allow...
7
by: oopsbabies | last post by:
Hello everyone, I am using Apache 1.3.33 as the web server and PHP version 4.3.10. My machine is using Windows XP 2002 professional edition which comes with a Windows firewall. I am using McAfee...
7
by: Rob Dob | last post by:
The following code is giving me a timeout problem., no matter what I do I can't send a piece of mail using .net2.0 System.Net.Mail.SmtpClient via port 465 and using ssl, if however I try using...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.