DoEvents

D

DS

I'm running this code with DoEvents, the "Transmitting" form now opens
to where I can see it, but last 2 commands "Close DX and Transmitting"
never happen, it seems that the code just keeps running. Do you have to
close or terminate the Do Events for the 2 forms to close at the end.
Thanks
DS

DoCmd.OpenForm "Transmitting"
DoEvents
'1 Allergys
DoCmd.TransferText acExportDelim, , "Allergys",
'Send Files
Const cdoSendUsingPort = 2
Const cdoBasic = 1
Dim objCDOConfig As Object, objCDOMessage As Object
Dim strSch As String

strSch = "http://schemas.microsoft.com/cdo/configuration/"
Set objCDOConfig = CreateObject("CDO.Configuration")
With objCDOConfig.Fields
.Item(strSch & "sendusing") = cdoSendUsingPort
.Item(strSch & "smtpserver") = "mail.optonline.net"
' Only used if SMTP server requires Authentication
.Item(strSch & "smtpauthenticate") = cdoBasic
.Item(strSch & "sendusername") = "DS"
.Item(strSch & "sendpassword") = "123"
.Update
End With

Set objCDOMessage = CreateObject("CDO.Message")
With objCDOMessage
Set .Configuration = objCDOConfig
.FROM = "Site 1"
.sender = "(e-mail address removed)"
.to = Forms!DX!EmailAddress
.Subject = Date & "" & "Site 1 Famous Restaurant"
.HTMLBody = "Todays Update!"
.AddAttachment "C:\DX\TFILE\DX1Allergys.txt"
.Send
End With
Set objCDOMessage = Nothing
Set objCDOConfig = Nothing
DoCmd.Close acForm, "Transmitting"
DoCmd.Close acForm, "DX"

End Sub
 
K

Ken Snell \(MVP\)

Not sure where your code is "hung", but you should close the two CDO objects
before you set them to Nothing:

objCDOMessage.Close
Set objCDOMessage = Nothing
objCDOConfig.Close
Set objCDOConfig = Nothing
 
D

DS

Ken said:
Not sure where your code is "hung", but you should close the two CDO objects
before you set them to Nothing:

objCDOMessage.Close
Set objCDOMessage = Nothing
objCDOConfig.Close
Set objCDOConfig = Nothing
Thanks Ken, I added those lines to the code.
DS
 
D

DS

Ken said:
Not sure where your code is "hung", but you should close the two CDO objects
before you set them to Nothing:

objCDOMessage.Close
Set objCDOMessage = Nothing
objCDOConfig.Close
Set objCDOConfig = Nothing
Ken, just tried add the above lines and the 2 close lines wouldn't
execute, "Object doesn't support this property method"
Thanks
DS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

WildCard 16
Sending E-mail 3
Sending E-Mail 11
Using the CDO object to send email... 3
Form Not Visible 2
Send email to exchange versus SMTP 1
CDO & MailMessage problem 2
Sending Access mail using smtp 1

Top