Search code examples
vbavb.netoutlookappointment

Is it possible to register an appointment in several Outlook accounts since vb?


I am using the following code but I only registered the appointment in the main mail account, I would like to know it is possible to register the direct appointment in another Outlook account:

.Recipients.Add("Roger Harui")
            Dim sentTo As Outlook.Recipients = .Recipients
            Dim sentInvite As Outlook.Recipient
            sentInvite = sentTo.Add("Holly Holt")
            sentInvite.Type = Outlook.OlMeetingRecipientType.olRequired

Solution

  • The Send method sends an item using the default account specified for the session.

    Private Sub CreateMeeting()
      Dim appt As Outlook.AppointmentItem = _
        CType(Application.CreateItem( _
        Outlook.OlItemType.olAppointmentItem), Outlook.AppointmentItem)
      appt.Subject = "Customer Review"
      appt.MeetingStatus = Outlook.OlMeetingStatus.olMeeting
      appt.Location = "36/2021"
      appt.Start = DateTime.Parse("19/04/2017 10:00 AM")
      appt.End = DateTime.Parse("19/04/2017 11:00 AM")
      Dim recipRequired As Outlook.Recipient = _
          appt.Recipients.Add("Ryan Gregg")
      recipRequired.Type = _
          Outlook.OlMeetingRecipientType.olRequired
      Dim recipOptional As Outlook.Recipient = _
          appt.Recipients.Add("Peter Allenspach")
      recipOptional.Type = _
          Outlook.OlMeetingRecipientType.olOptional
      Dim recipConf As Outlook.Recipient = _
          appt.Recipients.Add("Conf Room 36/2021 (14) AV")
      recipConf.Type = _
          Outlook.OlMeetingRecipientType.olResource
      appt.Recipients.ResolveAll()
      appt.Send()
    End Sub
    

    See How to: Specify Different Recipient Types for an Appointment Item for more information.