none
vb.net appointment scheduling app appointment does not release on shared calendar Office 365 RRS feed

  • Question

  • Hello,

    I am having an issue with a vb.net program that we use for scheduling appointments. We converted to a shared calendar/email account for scheduling and the code is not releasing the appointment once it is scheduled. Long story short, the app creates the appointment based on the specific information outlined. The issue starts when another appointment is created. Instead of creating a new separate appointment, it modifies the existing appointment that was already created. Posting code below. Any help is much appreciated.

    Private Sub btnSchedule_NA_Click(sender As Object, e As EventArgs) Handles btnSchedule_NA.Click
            Dim olApp As Outlook.Application = New Outlook.Application()
            Dim olNS As Outlook.NameSpace = olApp.Session
            Dim olFolder As Outlook.MAPIFolder = olNS.Folders.Item("Shared Calendar")
            olFolder = olFolder.Folders.Item("Calendar")
            Dim olAppItem As Outlook.AppointmentItem
            olAppItem = CType(olFolder.Items.Item(Outlook.OlItemType.olAppointmentItem), Outlook.AppointmentItem)
            Dim StartTime As String = Convert.ToDateTime(dtpDateOfAppointment_NA.Text & " " & cbAppointmentStart_NA.Text)
            Dim EndTime As String = Convert.ToDateTime(dtpDateOfAppointment_NA.Text & " " & cbAppointmentEnd_NA.Text)
    
            'CONSTRUCT OUTLOOK APPOINTMENT DATA STRING FOR REPORTING PURPOSES
            olAppItem.Subject = txtFirstName_NA.Text & "," & txtLastName_NA.Text & "," & cbService_NA.Text & "," & txtNotes_NA.Text & "," & txtReason_NA.Text & "," & dtpDate_NA.Text
            olAppItem.Body = txtComments_NA.Text
            olAppItem.Location = txtServiceAddress_NA.Text & "," & txtCity_NA.Text & "," & cbState_NA.Text & "," & txtZipCode_NA.Text
    
            olAppItem.Start = StartTime
            olAppItem.End = EndTime
    
            olAppItem.ReminderSet = True
            olAppItem.ReminderMinutesBeforeStart = 15
            olAppItem.BusyStatus = Outlook.OlBusyStatus.olBusy
            olAppItem.IsOnlineMeeting = False
            olAppItem.MeetingStatus = Outlook.OlMeetingStatus.olMeeting
            olAppItem.ResponseRequested = Outlook.OlResponseStatus.olResponseTentative
    
            olAppItem.RequiredAttendees = cbEmail_NA.Text
            olAppItem.Categories = cbAppointmentType_NA.Text
    
            olAppItem.Send()
    
            releaseObject(EndTime)
            releaseObject(StartTime)
            releaseObject(olAppItem)
            releaseObject(olFolder)
            releaseObject(olNS)
            releaseObject(olApp)
    
            EndTime = Nothing
            StartTime = Nothing
            olAppItem = Nothing
            olFolder = Nothing
            olNS = Nothing
            olApp = Nothing
    
            Dim MessageBox As MessageBox
            MessageBox = New MessageBox
            MessageBox.Show()
            MessageBox = Nothing
    Monday, June 11, 2018 8:39 PM

Answers

  • Helloo businessmanger18,

    >>olAppItem = CType(olFolder.Items.Item(Outlook.OlItemType.olAppointmentItem), Outlook.AppointmentItem)

    I think the code does not create a new olAppointmentItem, it does get an existing appointment item and then updated it. So next time, it will also get the appointment and then try to update it.

    If you want to create a new appointment item in this folder, I  would suggest you try below code.

     olAppItem = olFolder.Items.Add(Outlook.OlItemType.olAppointmentItem)

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, June 12, 2018 5:49 AM

All replies

  • Helloo businessmanger18,

    >>olAppItem = CType(olFolder.Items.Item(Outlook.OlItemType.olAppointmentItem), Outlook.AppointmentItem)

    I think the code does not create a new olAppointmentItem, it does get an existing appointment item and then updated it. So next time, it will also get the appointment and then try to update it.

    If you want to create a new appointment item in this folder, I  would suggest you try below code.

     olAppItem = olFolder.Items.Add(Outlook.OlItemType.olAppointmentItem)

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, June 12, 2018 5:49 AM
  • Awesome! Thank you for the quick response. I will try this and let you know what happens!

    Thanks,

    Josh

    Tuesday, June 12, 2018 1:30 PM
  • Thank you so much, Terry! I just tried your suggestion and it worked like a charm! Appreciate the help!

    Josh

    Tuesday, June 12, 2018 2:21 PM