|
Note
|
Required applications
|
| The code example in this topic can be compiled only if you have the required applications installed. For more information, see Features Available by Product Combination. | -
One of these development environments:
VSTO 2005
-or-
Visual Studio Team System
-
Microsoft Office Outlook 2003 |
This example gets a reference to a named custom folder and then displays the contents of the folder.
Example
Private Sub SetCurrentFolder()
Dim folderName As String = "TestFolder"
Dim inBox As Outlook.MAPIFolder = Me.ActiveExplorer().Session. _
GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
Try
Me.ActiveExplorer().CurrentFolder = inBox.Folders(folderName)
Me.ActiveExplorer().CurrentFolder.Display()
Catch
MessageBox.Show("There is no folder named " & folderName & _
".", "Find Folder Name")
End Try
End Sub
private void SetCurrentFolder()
{
string folderName = "TestFolder";
Outlook.MAPIFolder inBox = (Outlook.MAPIFolder)
this.ActiveExplorer().Session.GetDefaultFolder
(Outlook.OlDefaultFolders.olFolderInbox);
try
{
this.ActiveExplorer().CurrentFolder = inBox.
Folders[folderName];
this.ActiveExplorer().CurrentFolder.Display();
}
catch
{
MessageBox.Show("There is no folder named " + folderName +
".", "Find Folder Name");
}
}
Compiling the Code
See Also