SMTP slower for bulk mailing. How to use Exchange server instead using ASP ?

I have an application which is written in ASP which runs on IIS 4 using CDONTS and SMTP server. The problem with this is it is taking a long time to send mails if I want to send the mail to a larger group of recipients. It potentially freezes my server for long time. Looks like the implementation of SMTP is such a way that it will take the message and try to send to each recipient seperately. I heard that Exchange server is the best option in such situation. I have an exchange server running on the same network. Can I use that for sending mails with out using SMTP. Is it just a configuration change or do I need to recode the page to use exchange server. Any one has this kind of experience ? Your help will be highly appreciated
Who is Participating?
mgfranzConnect With a Mentor Commented:
Oh I see... you are creating a single message with BCC: as the recipient list.  It has been my experience that this is going to be much slower than sending messages on a loop, let's think about this for a second.  In BCC: mail, I need to first create a list of names, then send a message to each recipient at a single time.  If I loop through the names, and send a message to each recipient, I don't create an array list, and I don't send a bulk email, but individual messages.

Trust me, it is faster to send 1 messages to 1 recipient 1000 times than to send 1 message to 1000 recipients 1 times.  The message has to go through the entire list of names and send the message over and over again, with a simple loop, the message gets sent once, then again...  follow?
SMTP is the protocol most email servers use to process email, X400, POP3 are others.  Exchange and CDO use SMTP to process email messages.

If you are having problems processing emails, it might just be a problme with the script.

Post your code, but this is what I use to send bulk email.  The address's are stored in a .txt file with other info, I strip out the junk to get just the address then just run a loop on the resulting "match".  To process and send about 500 emails takes only about 5 seconds with CDONTS on my 2000 laptop;

Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.OpenTextFile("c:\inetpub\wwwroot\xyz.txt",1, true)
     strPhrase = ts.ReadAll
Dim objRegEx, Match, Matches, StrReturnStr
Set objRegEx = New RegExp
objRegEx.Global = True
objRegEx.IgnoreCase = True
objRegEx.Pattern = "~[^/]*"
Set Matches = objRegEx.Execute(strPhrase)

For Each Match in Matches

     theStr = Match.value
     theStr = Replace(theStr, "~", "")
          strTo = theStr&""
          strSubject = "Updates"
          strBody = "This message is being sent as a courtesy to all subscribers.  "
     strBody = strBody & vbCrLf  
     strBody = strBody & "I may not be getting to every subscriber, if you know someone who is on the xyz.Net system, please inform them of this issue."

Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
objCDOMail.From = "Mark G. Franz <>"
     objCDOMail.To = strTo
     objCDOMail.Subject = strSubject
     objCDOMail.Body = strBody
Set objCDOMail = Nothing
' Now write out who received the message.
Response.Write "Message sent to " & strTo & "!<br>"

rsajiAuthor Commented:
I am using the same code to send tha mail. But the difference is I will be sending the mail to 8000 recipients, all in different mail servers(ie,, etc). In your case you are sending the mail to the a set of recipients in the same server, that is why it may be faster. In this case case we are using the SMTP server. The alternative I am looking for is the Exchange server one with out using the SMTP server. The protocol internally used by Exchange server may be SMTP.
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

It's irrelevant that the recipients are on the same domain, remember, once the message has been processed and sent out on the internet cloud, SMTP and CDO don't care where it goes.  Once the message is processed, my script sends the next one.

I think you may have something else going on... Post your code.
rsajiAuthor Commented:
Here is my code. I am using html format for the mail body

          RecepList = ""
          SQL = "select emailaddress from users"
          set objRs = Server.CreateObject("ADODB.Recordset")
          objRs.CursorType = 3
          objRs.Open SQL, objConn, , , 1
          if objRs.eof = false then
               while objRs.EOF = false
                    if instr(1, objRs.Fields(0).Value, "@") > 0 then
                         if RecepList = "" then
                              RecepList = RecepList & objRs.Fields(0).Value
                              RecepList = RecepList & ";" & objRs.Fields(0).Value
                         end if
                    end if
               set objRs = nothing
          end if

          strBody = "<!DOCTYPE HTML PUBLIC""-//IETF//DTD HTML//EN"">"
          strBody = strBody & "<html>"
          strBody = strBody & "<head>"
          strBody = strBody & "<title>" & Request.Form("txtSubject").item & "</title>"
          strBody = strBody & "</head>"
          strBody = strBody & "<body bgcolor=""FFFFFF"">"
          if Request.Form("txtFontSize").Item  = "" then
               strBody = strBody & "<p><font size =""2"" face=" & Request.Form("cboFontType").Item & ">"
               strBody = strBody & "<p><font size =" & Request.Form("txtFontSize").Item & " face=" & Request.Form("cboFontType").Item & ">"
          end if
          strBody = strBody & Replace(Request.Form("txtText").Item, chr(10), "<BR>")
          if Request.Form("txtLink").Item <> "" then
               strBody = strBody & "<BR><BR>" & "For more information click on the following link"  
               strBody = strBody & "<BR>" &  "<a href=" & Request.Form("txtLink").Item & ">" & Request.Form("txtLink").Item & "</a>"
          end if
          strBody = strBody & "<BR><BR><BR><I>Disclaimer:<BR><BR>"
          strBody = strBody & Request.Form("txtDisclaimer").Item
          strBody = strBody & "<BR><HR>" & Request.Form("txtCopyright").Item  & "</I>"
          strBody = strBody & "</body>"
          strBody = strBody & "</html>"
          Set objMail = Server.CreateObject("CDONTS.NewMail")
          objMail.To = "User"
          objMail.Bcc = RecepList                                   'set 'To' address
          if Request.Form("txtReturn").Item <> "" then
               objMail.From = Request.Form("txtReturn").Item                    'set 'From' address
               objMail.Value("Reply-To") = Request.Form("txtReturn").Item 'set'Reply to' address
               objMail.From = "Unknown"
               objMail.Value("Reply-To") = "Unknown"
          end if
          objMail.Subject = Request.Form("txtSubject").item     'set the subject line
          objMail.BodyFormat=0 'for html data
          objMail.Body = strBody                                        
          objMail.Send                                                            'and send the message
          Set objMail = Nothing                                                  'then destroy the component
Check out your this opened question. Try to do something to it.

Under properties for SMTP server is IIS console, go to delivery/advanced/smart host. I've never done it, but I beleive ou can specify the address of your exchange server as the smart host. SMTP virutal server will then send the exchange server all of your messages, and let exchange server sort out the delivery. I don't know how SMTP & Exchange shake hands, perhaps someone else will be able to fill in the authentication details. But i think this is the general procedure.

The name JMail gets bandied about a lot as an alternative to CDONTS, but I know nothing about whether you can instruct it to hand off responsibility for message delivery to Exchange. But again, some else may be able to supply some more information.
part of your bottle neck might be 8000 string concatanations.  str = str & "something else"

when you are working with string concatanation, the larger the string gets, the slower it gets.  You might try commenting out the portion that sends the email to verify where your bottleneck is.

You might also try sending the email message out for every 50 entries. (if bottleneck is in string concatanation)
JMail uses either a local or remote SMTP server, so it really isn't a solution...
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.