Hi, I have a module in my database that creates an appointment based on a table of sessions. The module works in all respects, except two:
1) When I declare optional attendees it sometimes shows them as required attendees in the actual meeting in outlook, but not always
2) The .Send method does not seem to work. It creates the appointment on my calendar as the originator of the appointment, but does not send to the other recipients.
Can anyone shed some light on these two problems? Below is the code:
1) When I declare optional attendees it sometimes shows them as required attendees in the actual meeting in outlook, but not always
2) The .Send method does not seem to work. It creates the appointment on my calendar as the originator of the appointment, but does not send to the other recipients.
Can anyone shed some light on these two problems? Below is the code:
Code:
Private Sub SchedOutlook()
Dim rsEmployee As DAO.Recordset
Set rsEmployee = CurrentDb.OpenRecordset("Select * FROM Employee INNER JOIN tblSession ON Employee.EmpID = tblSession.EmpID;", dbOpenDynaset)
Dim rsMentor As DAO.Recordset
Set rsMentor = CurrentDb.OpenRecordset("Select * FROM Employee INNER JOIN tblSession ON Employee.EmpID = tblSession.MentorID;", dbOpenDynaset)
Dim rsSession As DAO.Recordset
Set rsSession = CurrentDb.OpenRecordset("SELECT * FROM tblSession WHERE HR_Apprvd = True AND Apt_in_outlk = False AND Cancelled = False;", dbOpenDynaset)
With rsSession
rsSession.MoveFirst
Do Until rsSession.EOF
Dim outobj As Outlook.Application
Dim outappt As Outlook.AppointmentItem
Set outobj = CreateObject("outlook.application")
Set outappt = outobj.CreateItem(olAppointmentItem)
With outappt
.Start = rsSession!Session_DT & " " & rsSession!Start_Time
.Duration = rsSession!Session_Duration
.RequiredAttendees = rsEmployee!Email_Address & "; " & rsMentor!Email_Address
.OptionalAttendees = rsEmployee!Manager_Email
.Subject = "Test Appointment"
.Body = "This is a test"
.Location = "Test"
.ReminderMinutesBeforeStart = 15
.ReminderSet = True
.Save
.Send
End With
If rsSession!Apt_in_outlk = False Then
rsSession.Edit
rsSession!Apt_in_outlk = True
rsSession.Update
End If
rsSession.MoveNext
Loop
End With
rsSession.Close
Set rsSession = Nothing
End Sub