Fetching all calendars from outlook 2007

K

K

Hi all,

In outlook 2007 we can create multiple calendar for a user. library
Microsoft.Office.Interop.Outlook is provided to fetch outlook data. i used it
to fetch multiple calendars but could not succeeded. i was doing:

Outlook.MAPIFolder outlookFolder =
outlookNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar);
MessageBox.Show(outlookFolder1.EntryID.ToString());

these commands gives only default folder. i could not find any way to fetch
rest of the calendars.

Is it possible to fetch all the calendars?? if possible plz guide me in this..

Thanks
K
 
A

Alan Moseley

Hi K

The code below is vba, but I'm sure that you can adapt it. It displays the
ID for each calendar located within the users mailbox. As you can see, the
ScanSubFolders routine recursively calls itself. This is so that folders
within folders are checked.

Public Sub GetAllCalendars()
Dim mbxfld As Outlook.MAPIFolder
Set mbxfld =
Outlook.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Parent
Dim fld As Outlook.MAPIFolder
For Each fld In mbxfld.Folders
If fld.DefaultItemType = olAppointmentItem Then
MsgBox (fld.EntryID)
End If
If fld.Folders.Count > 0 Then
Call ScanSubFolders(fld)
End If
Next fld
Set mbxfld = Nothing
End Sub
Private Sub ScanSubFolders(MyFolder As Outlook.MAPIFolder)
Dim fld As Outlook.MAPIFolder
For Each fld In MyFolder.Folders
If fld.DefaultItemType = olAppointmentItem Then
MsgBox (fld.EntryID)
End If
If fld.Folders.Count > 0 Then
Call ScanSubFolders(fld)
End If
Next fld
Set mbxfld = Nothing
End Sub
 

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