4

I'm sending an email using this code:

Set myMail=CreateObject("CDO.Message")
myMail.Subject="Sign-up"
myMail.From="support@abc.com"
myMail.To="support@abc.com"
myMail.HTMLBody = signup
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver")="smtp.1and1.com"
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=25 
myMail.Configuration.Fields.Update
myMail.Send
set myMail=nothing

and while this is executed, the page hangs. It takes about 5 to 10 seconds before it moves on. Apologies if this is trivial but do I need a separate queuing mechanism because I don't this on other websites. How are they doing this?

Calon
  • 4,174
  • 1
  • 19
  • 30
greener
  • 4,989
  • 13
  • 52
  • 93

1 Answers1

1

Does the mail get sent? You say it takes a few seconds before it moves on - what do you mean?

I looked at some of my asp cdo code that I have kicking around and I think you have to instantiate a CDO.Configuration object. Perhaps have a function that sets the config values for you, something like:

Function GetConfig()
Dim oConfig
Set oConfig = CreateObject("CDO.Configuration")
oConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    'etc...
     oConfig.Fields.Update
     Set GetConfig = oConfig
End Function
Andrew Cowenhoven
  • 2,778
  • 22
  • 27
  • The email gets sent OK. What I mean is that if I have a redirect happening after the message sending, that redirect occurs 5 secs after the user started sending the email. – greener Jan 14 '11 at 20:01
  • 5 secs is a little slow, but I could see it taking that long for CDO to contact the mail server and send the mail. Maybe you could use javascript to show a message telling the user that their mail is being sent and then the redirected page will confirm that it got sent. Also try instantiating the Configuration object above. Might speed it up. – Andrew Cowenhoven Jan 17 '11 at 14:09
  • 1
    Thanks Andrew. It did speed it up a little. – greener Jan 18 '11 at 22:43