views:

671

answers:

4

I am writing a newsletter application using CDO.Message. But get an error back that we have to many connections. Seems they have a limit of 10 simultaneous connections.

So, is there a way to send several messages on one connection, or disconnect faster? There is a cdo/configuration/smtpconnectiontimeout parameter, but I think that's more about how long the sender will try.

(If we send,ant it fails, it will succeed again after some minutes, probably meaning that the connection is disconnected).

(We are using CDO partly because we are pulling the HTML message body from a webserver)

Edit:

Public Sub ipSendMail(ByVal toEmail As String, ByVal fromEmail As String, ByVal subject As String, ByVal url As String)
 Dim iMsg As Object
 Set iMsg = CreateObject("CDO.Message")
 iMsg.From = fromEmail
 iMsg.To = toEmail
 iMsg.Subject = subject
 iMsg.CreateMHTMLBody(url)
 iMsg.Configuration.Fields.Item _
  ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
 iMsg.Configuration.Fields.Item _
  ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "relay.wwwwwwwwww.net"
 iMsg.Configuration.Fields.Item_
  ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
 iMsg.Configuration.Fields.Item _ 
  ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 0
 iMsg.Configuration.Fields.Update()
 iMsg.Send()
 Set iMsg = Nothing
End Sub
A: 

Ordinarily you only need one connection regardless of how many messages you are sending.

Perhaps you are not releasing something that you should be.

Edit: Just a thought, the SMTP server you are sending to, it wouldn't happen to be host on an XP box perhaps for testing reasons?

Edit: Ok so your SMTP server is fine.

What platform is the server supplying the result of the URL?

AnthonyWJones
All the examples I have seen starts with a CreateObject("CDO.Message").and ends with a .Send, I cant see how I can reuse one connection.(How to release is the question)
Olav
Well a CDO Message object doesn't necessarily represent a connection, and there is no reason why you can't re-use the CDO.Message object. Like I commented on the question, show us some code and we can help. I've done a lot of work with CDO sending multiple messages I've never had this problem.
AnthonyWJones
The SMTP is at the provider. Hope code I posted in comments above is readable. Though i think the only thing I could try regarding work flow is to keep one object, and reasign the fields for each message. (About XP - no idea, but it is at a provider, so I think it should be professional)
Olav
+1  A: 
  • Try to use SMTP instead of CDO, System.Web.Mail.SmtpMail
  • You could implement a queue, that is processed by a background thread. The background thread would only send one message at a time.
  • You can store the email in a database table, which is processed by a scheduled task or a stored procedure. Those can again send one mail at a time, and have the advantage of being able to retry, if it goes wrong.
Andomar
I know System.Web.Mail.SmtpMail, since it is one object it is more likely that I can reuse a connection. i do not know if I can do iMsg.CreateMHTMLBody(url)(it includes graphics in the message).(The main issue is being able to send more mails, and not block other users of our smtp)
Olav
An HTML body is just an attachment of type text/html. You can add it to the Attachments collection of SmtpMail.
Andomar
The point is that CDO converts so that graphics is included directly in the email
Olav
Is the HTML body fixed? i.e. is the "url" the same for every addressee? if so, you could try to mail using the same object and just changing the to address.
Andomar
A: 

I know that CDO can be quirky at times, so these are the possible suggestions that I would make:

A queue would probably work the best for you. After that, I would consider setting up a local SMTP server without inbound connection limits that uses a smarthost to queue up your outbound messages. (This could actually be written fairly easily. The "S" is for "Simple" and it actually is.)

If all else fails... You could always roll your own mailer component implementing RFCs 2821 and 2822 (or whatever the latest and greatest RFCs are for SMTP and message format)

EDIT: If the newsletter you are sending out is identical for all recipients, you can address it to a dummy recipient (i.e. [email protected]) and BCC it to the recipient list (or a subset of the recipient list). Just be careful not to get flagged as unsolicited commercial email. Let your provider know what you are doing. They have to deal with the complaints, and you are the one paying the bill. Letting them know that complaints would be mostly unwarranted (and few and far between) will help to assuage their natural risk aversion.

smbarbour
A: 

Hi,

Have you been able to solve the problem "Too many connections"? If so how?

Thanks, Jason

NiGhtOwL