Jump to content

ASP CDO email


justsomeguy

Recommended Posts

I used to use CDONTS.NewMail to send email, but obviously with Windows Server 2003 that is no longer an option, and I am using CDO.Message now. I have a script that does a lot of database processing, number crunching, and eventually sends out emails. The script runs daily. Theoretically, it might need to send out on the order of 2,000 emails, or it might only need to send 5. In my local test environment, I have it running and set up so that I can say whether or not it is allowed to send emails. When it is not allowed to send email, it will run through the entire script in about 5 seconds. When it does send email, it takes about 6 minutes to execute and send 272 emails. So the difference between 272 emails and none is apparently 6 minutes. I can sit there and watch it too, it takes over 1 second between displaying messages about sending email, where it spits everything out very quick if it doesn't have to email.So my question is, is there a more efficient way to send a lot of email? I turned up the script timeout to 20 minutes, but if it has a lot of email to send I want to make sure that it will get everything sent before it times out. Is there a sane way to send email that doesn't take over a second to send each message? 2,000 emails would require almost 45 minutes to send, and that's a little rediculous.I am using this function to send an email, so this function gets executed each time I send an email:

function send_email_func (to, from, subject, body){  mailobj = Server.CreateObject("CDO.Message");  mailobj.From = from;  mailobj.To = to;  mailobj.Subject = subject;  mailobj.TextBody = body;  mailobj.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2;  mailobj.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mailbox.domain.com";  mailobj.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25;  mailobj.Configuration.Fields.Update();  mailobj.Send();  delete mailobj;}

Does it actually sit there and wait for a response from the mail server before moving on? And if so, is there a way to disable that? I have tried for a while to find a decent reference for the CDO.Message object, and I can't find anything. I find tons of examples, all over the place, but the instructions are always "copy and paste this code and change the marked parts". Well I don't want to copy and paste, I want to know what it's doing, why it's doing it, and, most especially, what my other alternatives are. I'm just looking for a simple list of properties and methods available for the CDO.Message object, you would think that Microsoft would sort of be interested in helping programmers use the things that Microsoft requires them to use, but I guess you'd be wrong..Does anyone else feel like they need a shower after writing ASP?

Link to comment
Share on other sites

Good lord. Apparently the problem is the "sendusing" field being set to 2. If the field is set to 2, that means send using port (and get this, if Outlook Express is installed, it uses OE to send the mail, go Microsoft!). If sendusing is set to 1, then it uses the local pickup directory. I forgot what 3 does.Also, if anyone is looking for the CDO.Message reference, you can find it here on MSDN:MSDN Home > MSDN Library > Servers and Enterprise Development > Exchange Server > Microsoft Exchange 2000 Server > SDK Documentation > Microsoft Exchange 2000 SDK December 2005 > Reference > CDOEX > Interfaces > IMessage InterfaceI don't know why I didn't look there earlier, it should have been obvious.OK, I need a drink. And a shower. Resume general banter.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...