我有一個winforms應用程序,我試圖創建一個將創建一個新的Outlook約會的方法。 我正在使用以下代碼,但在創建對象newAppointment
的部分中標記了一個錯誤。如何用vb在outlook中創建約會?
Private Sub AddAppointment()
Dim newAppointment As Outlook.AppointmentItem = Me.Application.CreateItem _
(Outlook.OlItemType.olAppointmentItem)
Try
With newAppointment
.Start = Date.Now.AddHours(2)
.End = Date.Now.AddHours(3)
.Location = "ConferenceRoom #2345"
.Body = _
"We will discuss progress on the group project."
.Subject = "Group Project"
.AllDayEvent = False
.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
sentInvite = sentTo.Add("David Junca")
sentInvite.Type = Outlook.OlMeetingRecipientType.olOptional
sentTo.ResolveAll()
.Save()
.Display(True)
End With
Catch ex As Exception
MessageBox.Show("The following error occurred: " & _
ex.Message)
End Tryenter code here
End Sub
感謝您的幫助,它解決了這個問題,您只是救了我 – JoseEduardo