Directing appointment to calendar in the public folder instead?

J

jesslyn

Hi,
I have created a program that adds appointment to calendar in outlook.
But i need it to add to the calendar in the public folder instead of
the default personal folder. I tried changing the following codes but
it doesnt seem to be able to locate my public calendar.

Orginal: (adds to personal calendar folder)
Set ns = Outlook.Application.GetNamespace("MAPI")
Set fld = ns.GetDefaultFolder(olFolderCalendar)
Set itms = fld.Items
Set myform = itms.Add("IPM.Appointment.GroupAppt")

Change:
Set ns = Outlook.Application.GetNamespace("MAPI")
Set fld = ns.Folders("calendar_public")
Set fld = fld.Folders("testCalendar1")
Set itms = fld.Items
Set myform = itms.Add("IPM.Appointment.GroupAppt")

Do assist me.... thank you

regards
jesslyn
 
S

Sue Mosher [MVP]

You're on the right track, but if you stepped through your code you'd find
that ns.Folders("calendar_public") returns Nothing, because there is no
top-level folder hierarchy named "calendar_public"). The hierarchy you're
looking for starts with Public Folders: look at the folder list.

You can also use a function that walks the folder hierarchy. See
http://www.slipstick.com/dev/code/getfolder.htm

FYI, there is a newsgroup specifically for general Outlook programming
issues "down the hall" at microsoft.public.outlook.program_vba
 
J

jesslyn

Hi Sue Mosher,
Thanks for your great help. I have solve the problem already.

regards
jesslyn
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top