2017-06-15 94 views
0

我想將約會添加到共享的Outlook日曆中。我知道如何從MS Access添加到其他人的日曆中,但我在共享日曆方面遇到了問題。日曆的創建者也有自己的個人日曆。我以前的所有嘗試都已添加到他們的個人日曆中。MS Access - 將約會事件添加到共享的Outlook日曆

這是我的代碼...我試着在各種網站上收集代碼,我只是卡住了。我感謝任何幫助。

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

您將學習如何使用上的錯誤繼續下一步,如果你打算再次使用它保存幾年你的生活。 – niton

回答

1

更換線

outMail = Outlook.CreateItem(olAppointmentItem) 
... 
outMail.Send 

outMail = objFolder.Items.Add 
... 
outMail.Save 
相關問題