Sending the Outlook Appointment

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
 
G

Guest

OK, so after I found my brain, I changed "Appt" to "Task" and made a few
other appropriate chanegs in the routine so now the "Task" is sent as was
intended.

Another question - Is there a way to circumvent the "someone is attempting
to access your address book" message and the "Something is attempting to send
an email, do you want to allow it?" message? I have tried to find settings
in Outlook but without success.

Thanks,

Jim
 

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