LeeJames75
MIS
This is my code to run an overall mass mail of all emails in a query in BCC.
This works fine.
Public Sub Command4_Click()
Dim otk As Outlook.Application
Dim eml As Outlook.MailItem
Dim rs As Recordset
Dim Strlist As String
' Opens the table/query and builds the distribution list
Set rs = New ADODB.Recordset
With rs
.Open "qry_email", CurrentProject.Connection, adOpenKeyset, adLockOptimistic, adCmdTable
.MoveFirst
Set otk = CreateObject("Outlook.Application")
Set eml = otk.CreateItem(olMailItem)
Do While Not .EOF
Strlist = Strlist & .Fields("Email Address").Value & ";"
'This bit is for automatic same report emails -
'eml.Subject = "Test Message"
'eml.Body = "This is another test from access email program."
' use the following to add multiple Attachments
'eml.Attachments.Add "S:\ESC\LJames\invoice.xls"
'eml.Attachments.Add "S:\ESC\LJames\invoice2.xls"
.MoveNext
Loop
.Close
eml.BCC = Strlist
'This will show the email you are sending ideal for manual editing
eml.Display
'This will automatically send the email without showing the email
' eml.Send
End With
End Sub
I then have 2 more queries which relate to 3 groups,
Skaters, BMXers and Blades.
Therefore 3 more buttons and 3 queries.
I have replaced each query name in .OPEN
However, when I hit any of the command buttons for the Skaters or BMXers or Blades.
I get the following error.
RUN TIME ERROR 3021
Either BOF or EOF is TRUE, or the current record has been deleted.
Requested Operation requires a current record.
The overall email query has 10 test records.
So do the other 3 queries.
What have I missed out. Do I need to reset a value ??
All solutions will get a star !!!!
Regards
Lee James
England
This works fine.
Public Sub Command4_Click()
Dim otk As Outlook.Application
Dim eml As Outlook.MailItem
Dim rs As Recordset
Dim Strlist As String
' Opens the table/query and builds the distribution list
Set rs = New ADODB.Recordset
With rs
.Open "qry_email", CurrentProject.Connection, adOpenKeyset, adLockOptimistic, adCmdTable
.MoveFirst
Set otk = CreateObject("Outlook.Application")
Set eml = otk.CreateItem(olMailItem)
Do While Not .EOF
Strlist = Strlist & .Fields("Email Address").Value & ";"
'This bit is for automatic same report emails -
'eml.Subject = "Test Message"
'eml.Body = "This is another test from access email program."
' use the following to add multiple Attachments
'eml.Attachments.Add "S:\ESC\LJames\invoice.xls"
'eml.Attachments.Add "S:\ESC\LJames\invoice2.xls"
.MoveNext
Loop
.Close
eml.BCC = Strlist
'This will show the email you are sending ideal for manual editing
eml.Display
'This will automatically send the email without showing the email
' eml.Send
End With
End Sub
I then have 2 more queries which relate to 3 groups,
Skaters, BMXers and Blades.
Therefore 3 more buttons and 3 queries.
I have replaced each query name in .OPEN
However, when I hit any of the command buttons for the Skaters or BMXers or Blades.
I get the following error.
RUN TIME ERROR 3021
Either BOF or EOF is TRUE, or the current record has been deleted.
Requested Operation requires a current record.
The overall email query has 10 test records.
So do the other 3 queries.
What have I missed out. Do I need to reset a value ??
All solutions will get a star !!!!
Regards
Lee James
England