473,398 Members | 2,088 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Sending email hangs Access 2003

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
1 3807
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Setya Nugraha Djajadinata | last post by:
Hi all, I try to open an mdb and it gives error message : The database 'c:\MyDB\PDz.mdb' needs to be repaired or isn't a database file. You or another user may have been unexpectedly quit...
2
by: Del | last post by:
I have two question on sending email messages from MS Access (Versio 2000, 2002, and 2003). I have a form with a command button to send an email message, the code behide the button is as follows;...
1
by: Devonish | last post by:
I am composing an email with Access VB and then sending it from within Access. Everything works correctly (the email actually goes!) but Outlook ask some irritating questions that the user is...
0
by: Mike Knight | last post by:
(I've also posted this problem on microsoft.public.excel.programming) I have a MS Access 2003 Database named "AS400 Fields.mdb". This database contains links to tables on an AS400. In MS...
7
by: Marcin | last post by:
Hello all! A few years ago I created a form with button which let me send an email with an attachment. It was created in Access 97. Now I would like to move this application into Access 2003....
1
by: festivalman | last post by:
Hi, sorry if this is in the wrong spot. Finding the newsgroups on MS's site could have been easier Here's my problem I've got some old asp's that are running our simple web site. In a section,...
0
by: Bob Alston | last post by:
I am having trouble on a client PC getting the Office link, to send an access report I am viewing to MS Word. Also I cannot get send to - mail recipient to work either. The command box pops up...
1
by: Eric Sheu | last post by:
Greetings, I have been searching the web like mad for a solution to my SMTP problem. I am using Windows Server 2003 and ASP.NET 2.0 w/ C# to send out e-mails from a web site I have created to...
0
by: Lauren Wilson | last post by:
What is going on with this? We created an installer for Access 2003 Runtime using the P & D Wizard from Access 2003 Dev Extensions. It appeared to be fine but on some computers it simply hangs...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.