Run-time error 2004 out of memory.Help

P

padsoft

I want to send e-mails in an automaitc way from Access 2000.
I use Microsoft Outlook 2000.
I have found the VB-code and sometimes it is working.
Than suddenly I get an run-time error 2004 and cannot send any mai
anymore.
If I shut down access and start again 7 of the 40 mails are sent
beofre I get the error again. Sometimes I can sent 5 mails, sometime
12.
Here is the code:

Private Sub mail_Click()

Dim kantoor As String
Dim mail1 As String
Dim mail2 As String
Dim TELLER As Long: Dim TEL
Dim TELLER2 As Long
Dim ktrcontrol As Control
Dim mailcontrol As Control
Dim mailcontrol2 As Control
Dim Teksthead As String
DoCmd.SetWarnings False
TEL = 1
TELLER = 0
TELLER = DCount("*", "ADRES")

For TEL = 1 To TELLER
DoCmd.OpenTable "ADRES", acViewNormal, acEdit
DoCmd.GoToRecord acDataTable, "ADRES", acGoTo, TEL
DoCmd.GoToControl "ktr"
Set ktrcontrol = Screen.ActiveControl
kantoor = ktrcontrol
DoCmd.GoToControl "e-mail1"
Set mailcontrol = Screen.ActiveControl
mail1 = mailcontrol
DoCmd.GoToControl "e-mail2"
Set mailcontrol2 = Screen.ActiveControl
mail2 = mailcontrol

DoCmd.RunSQL " SELECT q_Output2.* " & _
" INTO T_YTI " & _
" FROM q_Output2 " & _
" WHERE (((q_Output2.Ktr)=""" & kantoor & """));"
TELLER2 = DCount("*", "T_YTI")
If TELLER2 <> 0 Then


Teksthead = "" & Chr(13) & "**AUTOMATISCHE MAIL**"
Chr(13) & Chr(13) & "Geachte collega," & Chr(13) & Chr(13) & "Bijgaan
een file." & Chr(13) & Chr(13) & "Best regards "
DoCmd.SendObject acSendTable, "T_YTI", acFormatXLS
mail1, mail2, , "Tekst""" & kantoor & """", Teksthead, False
DoCmd.OpenTable "T_YTI", acViewNormal
DoCmd.Close acTable, "adres", acSaveNo
DoCmd.Close acTable, "T_YTI", acsavono
Else
End If
Next

DoCmd.SetWarnings True
End Su
 

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

Top