我有一个在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()
你看到问题了吗?非常感谢。
首先,您需要设置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