I have the code below under a button on a form. At this point am just
testing how to send email from MS Access. Access is installed on a
machine running WinXP Pro. I checked the box next to Microsoft CDO
for Windows 2000 under References. I can send one message and then if
can close Access no problems. If I click the button several times to
send several emails then Access hangs. I have to use task manager to
kill it off. Either way, all of the emails get sent ok. Any ideas
why Access is hanging???
Thanks,
TD
Private Sub Command30_Click()
On Error GoTo Err_Command30_Click
Dim cdoConfig
Dim msgOne
Set cdoConfig = CreateObject("CDO.Configuration")
With cdoConfig.Fields
.Item(cdoSMTPServerPort) = 25
.Item(cdoSMTPServer) = "smtp.myisp.net"
.Item(cdoSMTPAuthenticate) = cdoBasic
.Item(cdoSendUserName) = "me@myisp.com"
.Item(cdoSendPassword) = "password"
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Update
End With
Set msgOne = CreateObject("CDO.Message")
Set msgOne.Configuration = cdoConfig
msgOne.To = yo*@yourdomain.com
msgOne.From = "me@mydomain.com"
msgOne.Subject = "Test"
msgOne.TextBody = "It works just fine"
msgOne.Send
Set cdoConfig = Nothing
Set msgOne = Nothing
Exit_Command30_Click:
Exit Sub
Err_Command30_Click:
MsgBox Err.Description
Resume Exit_Command30_Click
End Sub