I have created a function to place appointments in my outlook calendar and this all works well.
The only issue is that it is not sending an email to the attendees and I can't seem to figure out why.
Even when I open the appointment, created in my calendar, the email address is there.
I have tried .display as well, however this just displayed the appointment but I still had to send it manually.
Any help would be appreciated.
The code is as followed.
CODE IS UPDATED AND IS WORKING CODE NOW!
The only issue is that it is not sending an email to the attendees and I can't seem to figure out why.
Even when I open the appointment, created in my calendar, the email address is there.
I have tried .display as well, however this just displayed the appointment but I still had to send it manually.
Any help would be appreciated.
The code is as followed.
CODE IS UPDATED AND IS WORKING CODE NOW!
Code:
Public Function UpdateOutlook()
Dim oRS As DAO.Recordset
Dim oOL As Outlook.Application
Dim oAppoint As Outlook.AppointmentItem
Dim sStart As String
Dim Port As String
Dim myRequiredAttendee As Outlook.Recipient
Set oRS = CurrentDb.OpenRecordset("ShipVissitReportQ")
Set oOL = New Outlook.Application
Set oAppoint = oOL.CreateItem(olAppointmentItem)
oRS.FindFirst "ShipsVisitID=" & CurID
OutlookSubj = oRS.Fields("VesselName") & " - OCEANIC SERVICES VESSEL VISIT REQUEST. - " & oRS.Fields("PortName")
With oAppoint
If IsNull(oRS.Fields("VisitDate")) Then
GoTo NoDate
Else
sStart = oRS.Fields("VisitDate") & " " & oRS.Fields("VisitTime")
End If
.Start = CDate(sStart)
.Duration = 240
.subject = OutlookSubj
If Not IsNull(oRS.Fields("Remarks")) Then
.Body = oRS.Fields("Remarks")
End If
Set myRequiredAttendee = .Recipients.Add("xxxxxxxx@gmail.com")
myRequiredAttendee.Type = olRequired
If IsNull(Forms!ShipVisitOverviewF!PortName) Then
MsgBox "there is no port assigned"
Else
MsgBox "there is port assigned!!!!"
.Location = oRS.Fields("PortName")
oRS.Edit
oRS!PortAss = True
oRS.Update
End If
.Categories = "Oceanic-Services"
.MeetingStatus = olMeeting 'this has been changed from olNonMeeting for it to work.
.Save
oRS.Edit
oRS!GlobalAppointmentID = .GlobalAppointmentID
oRS.Update
End With
oAppoint.Send
GoTo EndFunc
NoDate:
MsgBox "No date entered"
EndFunc:
oRS.Close
Set oRS = Nothing
Set oOL = Nothing
Set oAppoint = Nothing
End Function
Last edited: