By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,326 Members | 1,938 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,326 IT Pros & Developers. It's quick & easy.

Sending email hangs Access 2003

P: n/a
TD
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
Aug 15 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Since you've set a reference to CDO you can use early binding as in:

Public Sub SimpleSendMailWithCDOB()
'early binding
'requires reference to cdosys.dll

Dim iCfg As CDO.Configuration
Dim iMsg As CDO.Message

Set iCfg = New CDO.Configuration
Set iMsg = New CDO.Message

With iCfg.Fields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServerPort) = 25
.Item(cdoSMTPServer) = "smtp.cogeco.ca"
.Item(cdoSMTPAuthenticate) = cdoBasic
.Item(cdoSendUserName) = "username"
.Item(cdoSendPassword) = "password"
.Item(cdoSendEmailAddress) = "your name <your email address>"
..Update
End With

With iMsg
.Configuration = iCfg
.Subject = "Test Late Binding"
.To = "so*****@domain.tld"
.TextBody = "Test"
.send
End With

Set iMsg = Nothing
Set iCfg = Nothing

End Sub

This may help with Access's not releasing the pointers to cdoConfig
and/or msgOne before you recreate them. Then again it may not.

TD <dl**@adsi-sc.comwrote in news:bc7ae580-56fd-4584-ba25-8cdd8a833d10
@v16g2000prc.googlegroups.com:
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
Aug 15 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.