G
Guest
I am using the following code in Access to create appointments and need to
have it automatically send the appointment to team members. The email that
displays is empty of any attachments. The appointment goes into my calendar.
At work we are on the Microsoft Exchange Server if that makes a difference
in how the routine is set up.
Thanks,
Jim
Private Sub cmdCreateAppt_Click()
On Error GoTo Err_cmdCreateAppt_Click
Dim objOl As Outlook.Application
Dim objItem As Outlook.AppointmentItem
Dim blnOlRunning As Boolean
Dim txtApptDate As Date
Dim Recipients As String
On Error Resume Next
blnOlRunning = True
Set objOl = GetObject(, "Outlook.Application")
If Err <> 0 Then
Set objOl = CreateObject("Outlook.Application")
blnOlRunning = False
Err.Clear
End If
On Error GoTo 0
Set objItem = objOl.CreateItem(olAppointmentItem)
With objItem
.Start = CDate(Me.txtApptDate) ' + CDate(Me.txtApptTime)
.duration = Me.txtDuration * Me.ogDuration
.Subject = Me.txtSubject & vbNullString
.Body = Me.txtBody & vbNullString
.Recipients.Add (Me.Addresses)
.Save
End With
If blnOlRunning = True Then
objItem.Display
' objItem.Send
DoCmd.SendObject , (objItem), , (Me.Addresses), , , _
(Me.txtSubject), (Me.txtBody), True
Else
objOl.Quit
End If
Exit_cmdCreateAppt_Click:
Set objItem = Nothing
Set objOl = Nothing
Exit Sub
Err_cmdCreateAppt_Click:
Select Case Err
Case 0
Case Else
MsgBox Err.Description
Resume Exit_cmdCreateAppt_Click
End Select
End Sub
have it automatically send the appointment to team members. The email that
displays is empty of any attachments. The appointment goes into my calendar.
At work we are on the Microsoft Exchange Server if that makes a difference
in how the routine is set up.
Thanks,
Jim
Private Sub cmdCreateAppt_Click()
On Error GoTo Err_cmdCreateAppt_Click
Dim objOl As Outlook.Application
Dim objItem As Outlook.AppointmentItem
Dim blnOlRunning As Boolean
Dim txtApptDate As Date
Dim Recipients As String
On Error Resume Next
blnOlRunning = True
Set objOl = GetObject(, "Outlook.Application")
If Err <> 0 Then
Set objOl = CreateObject("Outlook.Application")
blnOlRunning = False
Err.Clear
End If
On Error GoTo 0
Set objItem = objOl.CreateItem(olAppointmentItem)
With objItem
.Start = CDate(Me.txtApptDate) ' + CDate(Me.txtApptTime)
.duration = Me.txtDuration * Me.ogDuration
.Subject = Me.txtSubject & vbNullString
.Body = Me.txtBody & vbNullString
.Recipients.Add (Me.Addresses)
.Save
End With
If blnOlRunning = True Then
objItem.Display
' objItem.Send
DoCmd.SendObject , (objItem), , (Me.Addresses), , , _
(Me.txtSubject), (Me.txtBody), True
Else
objOl.Quit
End If
Exit_cmdCreateAppt_Click:
Set objItem = Nothing
Set objOl = Nothing
Exit Sub
Err_cmdCreateAppt_Click:
Select Case Err
Case 0
Case Else
MsgBox Err.Description
Resume Exit_cmdCreateAppt_Click
End Select
End Sub