【问题标题】:Creating an Outlook Appointment doesn´t add recipients创建 Outlook 约会不会添加收件人
【发布时间】:2020-07-25 17:59:57
【问题描述】:

我有一个在 Outlook 中创建约会的功能。我的问题是,它没有添加任何收件人。我使用 CheckedListBox 和仅使用字符串(硬编码)进行了尝试,但它不起作用。 约会本身已创建,但没有收件人..

这是我的代码:

  Dim app As Microsoft.Office.Interop.Outlook.Application
        Dim appt As Microsoft.Office.Interop.Outlook.AppointmentItem

        app = New Microsoft.Office.Interop.Outlook.Application
        appt = app.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olAppointmentItem)
        appt.Subject = tbBetreff.Text
        appt.Body = tbInhalt.Text
        appt.Location = tbOrt.Text

        For Each itemChecked In cbContacts.CheckedItems
            Dim sentTo As Outlook.Recipients = appt.Recipients
            Dim sentInvite As Outlook.Recipient
            sentInvite = sentTo.Add(itemChecked.ToString())
            sentInvite.Type = Outlook.OlMeetingRecipientType.olRequired
            sentTo.ResolveAll()
        Next

        appt.Start = Convert.ToDateTime("24.07.2020 13:00:00")
        appt.End = Convert.ToDateTime("24.07.2020 14:00:00")
        appt.ReminderSet = True
        appt.ReminderMinutesBeforeStart = 30

        appt.Save()

你看到问题了吗? 谢谢。。

【问题讨论】:

    标签: vb.net outlook


    【解决方案1】:

    首先,您需要设置AppointmentItem.MeetingStatus 属性,该属性设置一个OlMeetingStatus 常量,指定约会的会议状态。然后您可以添加与会者。

    以下示例代码以编程方式创建约会、设置各种属性并发送约会以请求会议。 CreateAppt 使用 CreateItem` 方法创建一个 AppointmentItem 对象。它将 AppointmentItem 的 MeetingStatus 属性设置为 olMeeting 以将约会指示为会议请求,并将必需的与会者、可选的与会者和会议地点设置为资源。该示例然后显示并发送约会项目。

    Sub CreateAppt() 
     Dim myItem As Object 
     Dim myRequiredAttendee, myOptionalAttendee, myResourceAttendee As Outlook.Recipient 
     
     Set myItem = Application.CreateItem(olAppointmentItem) 
     myItem.MeetingStatus = olMeeting 
     myItem.Subject = "Strategy Meeting" 
     myItem.Location = "Conf Rm" 
     myItem.Start = #9/24/2020 1:30:00 PM# 
     myItem.Duration = 90 
     Set myRequiredAttendee = myItem.Recipients.Add("Eugene Astafiev") 
     myRequiredAttendee.Type = olRequired 
     Set myOptionalAttendee = myItem.Recipients.Add("Kevin Kennedy") 
     myOptionalAttendee.Type = olOptional 
     Set myResourceAttendee = myItem.Recipients.Add("Conf Rm All Stars") 
     myResourceAttendee.Type = olResource 
     myItem.Display 
    End Sub
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-13
      • 1970-01-01
      • 1970-01-01
      • 2023-03-06
      相关资源
      最近更新 更多