13.08.2012 Views

Groupwise Developer's Guide

Groupwise Developer's Guide

Groupwise Developer's Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

38<br />

Although this method can quickly run through an entire Folders collection, it<br />

leaves much to be desired, if you wish to find a particular folder, in part because<br />

you (and your code) may not know how the end user has ordered the folders in his<br />

or her account. If Index is a string, it represents a FolderID in which case<br />

Folders.Item(Index) will return the folder within the collection that has a<br />

matching FolderID. If the FolderID is invalid or refers to a folder that is not within<br />

the particular Folders collection, then the method will throw an exception. This<br />

too, leaves much to be desired, as a particular FolderID may be unknown. The<br />

following method accepts a folder name.<br />

Folders.ItemByName(Name as String)<br />

This is a tricky method; it will return the first instance of any given folder that<br />

matches Folder.Name. If, for example, you have several sub-folders with the same<br />

name but different parent folders, you should always check the Name property of<br />

Folder.ParentFolder to determine exactly which folder you have obtained.<br />

There is no way to make successive ItemByName() calls; thus, you may need<br />

to use the Item() method and iterate through all of the folders in order to find<br />

the folder you are looking for. Because ItemByName() may be called by any<br />

given Folders object, you can limit the folders in which you search. For<br />

example, you might search in the Cabinet, or you might iterate through each<br />

top-level folder in the cabinet using the Item() method and then call<br />

ItemByName() within each top-level folder’s collection. The following is an<br />

example procedure that searches each top-level folder for the first folder named<br />

‘MainFolder’ in each folder within the Cabinet (but it does not find folders in the<br />

Cabinet that happen to be called ‘MainFolder’):<br />

Example in VB:<br />

'gwAccount is a valid Account object<br />

Dim gwFolders As GroupwareTypeLibrary.Folders<br />

Dim gwFolder As GroupwareTypeLibrary.Folder2<br />

Dim gwCurrentFolder As GroupwareTypeLibrary.Folder2<br />

Private Sub FindFoldersByName()<br />

'Get the most recent Folders list.<br />

gwAccount.Refresh<br />

Set gwFolders = gwAccount.Cabinet.Folders<br />

If gwFolders.Count > 0 Then<br />

For i = 1 To gwFolders.Count<br />

Set gwCurrentFolder = gwFolders.Item(i)<br />

On Error GoTo FldrErr<br />

Set gwFolder = gwCurrentFolder.Folders.ItemByName("MainFolder")<br />

Next i<br />

End If<br />

www.novell.com/appnotes

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!