I am trying to create an appointment on a shared calender in public folders. I need to create the appointment and then send to the required and optional people. I am getting it to create the appointment, but it isnt sending the invite.
Here is my code. I have been searching all day for a solution before posting here, but I am losing my mind.
Here is my code. I have been searching all day for a solution before posting here, but I am losing my mind.
VB.NET:
Private Sub add_to_outlook(ByVal calendarpath As String(), ByVal br As Object)
Dim olApp As New Outlook.Application
Dim olNameSpace As Outlook.NameSpace
Dim olPublicFolder As Outlook.MAPIFolder
Dim olAppt As Outlook.AppointmentItem
olApp = CreateObject("Outlook.Application")
olNameSpace = olApp.GetNamespace("MAPI")
olPublicFolder = olNameSpace.Folders("Public Folders")
For i As Integer = 0 To calendarpath.Length - 1
If calendarpath(i) <> "" And calendarpath(i) <> "Public Folders" Then
olPublicFolder = olPublicFolder.Folders.Item(calendarpath(i))
End If
Next
olAppt = olPublicFolder.Items.Add
With olAppt
.Subject = ("Requested: " & br.project_name & "-" & Me.typeCombobox.SelectedValue)
.Location = br.bench_name
.Body = (br.notes)
.Start = CDate(br.requestdate & " " & br.start_time)
.ReminderMinutesBeforeStart = 15
.ReminderSet = True
.Duration = DateDiff(DateInterval.Hour, (br.requestdate & " " & br.start_time), (br.requestdate & " " & br.end_time))
For Each recip As String In br.requiredengineers
reqatt = reqatt & ";" & recip
.Recipients.Add(recip)
.Recipients(recip).Type = CInt(Outlook.OlMeetingRecipientType.olRequired)
Next
reqatt = Mid(reqatt, 2)
.RequiredAttendees = reqatt
For Each recip As String In br.optionalengineers
optatt = optatt & ";" & recip
.Recipients.Add(recip)
.Recipients(recip).Type = CInt(Outlook.OlMeetingRecipientType.olOptional)
Next
optatt = Mid(optatt, 2)
.OptionalAttendees = optatt
.Recipients.ResolveAll()
.Categories = "Yellow Category"
.ResponseRequested = True
.BusyStatus = Outlook.OlBusyStatus.olBusy
'.Save()
.Move(olPublicFolder)
.Send()
End With