E
Eric
I have a problem with a function that reference to
outlook. I'm need to loop thru a recordset to send e-
mails to selected users. The problem is that for some
strange reason the routine does not move to the 2nd
record in the recordset and I always get the following
error message: Method update not supported by automation
object.
This is the routine:
On Error GoTo Err_EMailGuests
Dim db As Database, rs1, rs2 As Recordset, strBody As
String
Set db = CurrentDb()
Set rs1 = db.OpenRecordset("SELECT * FROM tblResult")
Set rs2 = db.OpenRecordset("Select * from Activity")
Dim objOutlook, objOutlookMsg, oItem
Set objOutlook = CreateObject("Outlook.Application")
Dim addressee As String
addressee = rs1!Number
strBody = rs2!activity
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
rs1.MoveFirst
Do While Not rs1.EOF
With objOutlookMsg
.TO = addressee
.subject = rs2!subject
.Body = strBody
.Send
End With
rs1.MoveNext
Loop
GoTo EndEMailGuests
Err_EMailGuests:
DoCmd.Hourglass False
MsgBox (Error)
Resume EndEMailGuests
EndEMailGuests:
rs1.Close
rs2.Close
Set rs1 = Nothing
Set rs2 = Nothing
Set db = Nothing
Set objOutlook = Nothing
outlook. I'm need to loop thru a recordset to send e-
mails to selected users. The problem is that for some
strange reason the routine does not move to the 2nd
record in the recordset and I always get the following
error message: Method update not supported by automation
object.
This is the routine:
On Error GoTo Err_EMailGuests
Dim db As Database, rs1, rs2 As Recordset, strBody As
String
Set db = CurrentDb()
Set rs1 = db.OpenRecordset("SELECT * FROM tblResult")
Set rs2 = db.OpenRecordset("Select * from Activity")
Dim objOutlook, objOutlookMsg, oItem
Set objOutlook = CreateObject("Outlook.Application")
Dim addressee As String
addressee = rs1!Number
strBody = rs2!activity
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
rs1.MoveFirst
Do While Not rs1.EOF
With objOutlookMsg
.TO = addressee
.subject = rs2!subject
.Body = strBody
.Send
End With
rs1.MoveNext
Loop
GoTo EndEMailGuests
Err_EMailGuests:
DoCmd.Hourglass False
MsgBox (Error)
Resume EndEMailGuests
EndEMailGuests:
rs1.Close
rs2.Close
Set rs1 = Nothing
Set rs2 = Nothing
Set db = Nothing
Set objOutlook = Nothing