What am I forgetting in this code...

M

Maurice

Hi,

Specs: WinXP - Outlook 2003

I'm calling the Outlook object model from Access. I need to send
appointments based on a recordset. I have three records in the recordset
which are all appointments. I should get three different appointments but i'm
getting one with all the recipients added three times. Pleas take a look at
the code below and tell me what i'm missing:

Code created in Access...

Private sub CheckActions()
Dim rst as ADODB.recordset
Dim objApp as Outlook.Application
Dim objAppointment as Outlook.AppointmentItem

Set objApp =CreateObject("Outlook.Application")
Set objAppointment=objApp.CreateItem(olAppointmentItem)

Set rst=New ADODB.Recordset

rst.open "table",cuurentproject.connection, adOpenDynamic, adLockOptimistic

With rst
if not rst.BOF and not rst.EOF then
select case rst(2) '-> Field which says it's an appointment
with objAppointment
.MeetingStatus=olMeeting
.subject=rst("subjectMeeting")
. recipients.add (rst("addressee")
'-> ect.... (location, start ...)
. Send
end with

case=4 '-> do something else
this is where i do the mail which goes correct...
end select
rst.movenext
end if
end with
rst.close

End sub

My guess is that i have to set a 'new' appointment some how.

Any help appreciated...
 
K

Ken Slovak - [MVP - Outlook]

You're creating the appointment outside of the loop, so there's only one
appointment. Move the CreateItem line inside the loop.
 
M

Maurice

Ken,

Thanks for waking me up on this one. Sometimes your just looking at the code
to long to see the stupidity of it ;-)
Thanks again...
 

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