我想在共享的Outlook日历中添加约会。我知道如何从MS Access添加到其他人的日历中,但我遇到了共享日历的问题。日历的创建者也有自己的个人日历。我之前的所有尝试都刚刚添加到他们的个人日历中。
这是我的代码......我尝试在各种网站上收集代码,而我只是卡住了。我感谢任何帮助。
Private Sub Add_to_Shared_Calendar_Click()
Dim outMail As Outlook.AppointmentItem
Dim objNS As Outlook.NameSpace
Dim objFolder As Outlook.MAPIFolder 'get name of other persons folder
Dim objRecip As Outlook.Recipient 'other persons name
Dim strName As String 'the name or email of the persons folder
Dim objAppt As Outlook.AppointmentItem
Dim objApp As Outlook.Application
On Error Resume Next
' name of person whose Calendar you want to use - right?
strName = "John Smith - Project Name Shared Calendar"
Set objNS = objApp.GetNamespace("MAPI")
Set objRecip = objNS.CreateRecipient(strName)
Set objFolder = objNS.GetSharedDefaultFolder(objRecip, olFolderCalendar)
Set outMail = Outlook.CreateItem(olAppointmentItem)
outMail.Subject = "test"
outMail.Location = ""
outMail.MeetingStatus = olMeeting
outMail.Start = Me.dateofevent
outMail.End = Me.TimeofEvent
outMail.RequiredAttendees = strName
outMail.Body = "test message"
outMail.Send
Set outMail = Nothing
End Sub
答案 0 :(得分:1)
替换
行 outMail = Outlook.CreateItem(olAppointmentItem)
...
outMail.Send
带
outMail = objFolder.Items.Add
...
outMail.Save