Karen Schaefer
asked on
Creating Vacation Schedule with Approval in Outlook from Access
I am looking for code that will allow me to create in Access an vacation scheduling tool that will use the OUTLOOK options/data to send request for approval and then update the users Outlook calendar upon approval. I have seen many examples of the basic code for Access to send emails using Outlook, however, unable to find the functionality need to calendar/email notifications.
Can someone help point me in the right direction?
K
Can someone help point me in the right direction?
K
Here is some code to create appointments with reminders
Public Sub ExportCalendar()
'Created by Helen Feddema 5-19-2000
'Last modified 11-Apr-2010
On Error GoTo ErrorHandler
Dim appOutlook As New Outlook.Application
Dim itm As Outlook.AppointmentItem
Dim rcp As Outlook.Recipient
Dim strContactName As String
Dim strFolder As String
Dim nms As Outlook.NameSpace
Dim flds As Outlook.Folders
Dim blnFound As Boolean
Dim fld As Outlook.MAPIFolder
Dim itms As Outlook.Items
Dim appt As Outlook.AppointmentItem
strFolder = "Appointments from Access"
Set nms = appOutlook.GetNamespace("MAPI")
Set flds = nms.Folders("Personal Folders").Folders
Set nms = appOutlook.GetNamespace("MAPI")
'Check for existence of Appointments from Access folder and
'create it if not found
blnFound = False
For Each fld In flds
If fld.Name = strFolder Then
blnFound = True
End If
Next fld
If blnFound = True Then
Set fld = flds(strFolder)
ElseIf blnFound = False Then
Set fld = flds.Add(strFolder, olFolderCalendar)
End If
Set itms = fld.Items
'Get reference to data table
Set dbs = CurrentDb
'Create recordset based on query
Set rst = dbs.OpenRecordset("qryAppointments")
rst.MoveLast
rst.MoveFirst
lngCount = rst.RecordCount
'Loop through table, exporting each record to Outlook
Do Until rst.EOF
'Create an appointment item
Set appt = itms.Add("IPM.Appointment")
With appt
.Subject = Nz(rst![Topic])
.Categories = Nz(rst![Category])
.Start = Nz(rst![StartTime])
.End = Nz(rst![EndTime])
.Location = Nz(rst![Location])
.ReminderMinutesBeforeStart = 20
.ReminderOverrideDefault = True
.ReminderPlaySound = True
.ReminderSet = True
.ReminderSoundFile = "C:\Windows\Media\Tada.wav"
strContactName = Nz(rst![ContactName])
Debug.Print "Contact name: " & strContactName
If strContactName <> "" Then
'The Links collection corresponds to the Contacts button
'in the interface, and a link has to be a valid recipient,
'so we have to check that the FullName value is a valid
'Outlook contact before adding it as a link
Set rcp = nms.CreateRecipient(strContactName)
rcp.Resolve
If rcp.Resolved Then
.Links.Add rcp
Else
MsgBox "Can't add " & strContactName & _
" as a contact for this appointment"
End If
End If
.Close (olSave)
End With
rst.MoveNext
Loop
rst.Close
ErrorHandlerExit:
Exit Sub
ErrorHandler:
MsgBox "Error No: " & Err.Number & "; Description: " & Err.Description
Resume ErrorHandlerExit
End Sub
I forgot the line to set appOutlook (it was set globally in my module). Declare appOutlook as New Outlook.Application.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks for the assist
Add Appointments: http://support.microsoft.com/?kbid=209963
Add Tasks/Events: http://support.microsoft.com/?kbid=162371