Hey everyone:
I've read a few threads on doing this but my code still won't work. Trying to attach an appointment to a shared outlook calendar.
Here is the code:
Private Sub cmdAddAppt_Click()
Dim myOlApp As Outlook.Application
Dim objAppt As Object
Dim myNamespace As Outlook.Namespace
Dim HisCalendar As Outlook.MAPIFolder
Set myOlApp = CreateObject("Outlook.Application")
Set myNamespace = myOlApp.GetNamespace("MAPI")
Set myRecipient = myNamespace.CreateRecipient("XYZ")
myRecipient.Resolve
Set HisCalendar = myNamespace.GetSharedDefaultFolder(myRecipient, olFolderCalendar)
Set objAppt = myOlApp.CreateItem(olAppointmentItem)
With objAppt
.Start = Me.Loan_Closing_Date
.Duration = 60
.Subject = Me.Meeting
.Move HisCalendar
.Save
.Close (olSave)
End With
Set objAppt = Nothing
Set HisCalendar = Nothing
Set myRecipient = Nothing
Set Namespace = Nothing
Set objOutlook = Nothing
End Sub
Seem to have a problem at "Set HisCalendar" part, doesn't recognize names.
Any thoughts?
Thanks
David
I've read a few threads on doing this but my code still won't work. Trying to attach an appointment to a shared outlook calendar.
Here is the code:
Private Sub cmdAddAppt_Click()
Dim myOlApp As Outlook.Application
Dim objAppt As Object
Dim myNamespace As Outlook.Namespace
Dim HisCalendar As Outlook.MAPIFolder
Set myOlApp = CreateObject("Outlook.Application")
Set myNamespace = myOlApp.GetNamespace("MAPI")
Set myRecipient = myNamespace.CreateRecipient("XYZ")
myRecipient.Resolve
Set HisCalendar = myNamespace.GetSharedDefaultFolder(myRecipient, olFolderCalendar)
Set objAppt = myOlApp.CreateItem(olAppointmentItem)
With objAppt
.Start = Me.Loan_Closing_Date
.Duration = 60
.Subject = Me.Meeting
.Move HisCalendar
.Save
.Close (olSave)
End With
Set objAppt = Nothing
Set HisCalendar = Nothing
Set myRecipient = Nothing
Set Namespace = Nothing
Set objOutlook = Nothing
End Sub
Seem to have a problem at "Set HisCalendar" part, doesn't recognize names.
Any thoughts?
Thanks
David