Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
This example checks for a folder named HtmlView in Microsoft Office Outlook. If the folder does not exist, the code creates the folder and assigns a Web page to it. If the folder exists, the code displays the folder contents.
Applies to: The information in this topic applies to application-level projects for Outlook 2013 and Outlook 2010. For more information, see Features Available by Office Application and Project Type.
Example
Private Sub CreateHtmlView()
Dim newView As Outlook.MAPIFolder = Nothing
Dim viewName As String = "HtmlView"
Dim inBox As Outlook.MAPIFolder = Me.Application.ActiveExplorer(). _
Session.GetDefaultFolder(Outlook.OlDefaultFolders _
.olFolderInbox)
Dim searchFolders As Outlook.Folders = inBox.Folders()
Dim foundView As Boolean = False
For Each searchFolder As Outlook.MAPIFolder In searchFolders
If searchFolder.Name = viewName Then
newView = inBox.Folders(viewName)
foundView = True
End If
Next
If foundView = False Then
newView = inBox.Folders.Add(viewName, _
Outlook.OlDefaultFolders.olFolderInbox)
newView.WebViewURL = "https://www.microsoft.com"
newView.WebViewOn = True
End If
Application.ActiveExplorer.SelectFolder(newView)
Application.ActiveExplorer.CurrentFolder.Display()
End Sub
private void CreateHtmlFolder()
{
Outlook.MAPIFolder newView = null;
string viewName = "HtmlView";
Outlook.MAPIFolder inBox = (Outlook.MAPIFolder)
this.Application.ActiveExplorer().Session.GetDefaultFolder(Outlook
.OlDefaultFolders.olFolderInbox);
Outlook.Folders searchFolders = (Outlook.Folders)inBox.Folders;
bool foundView = false;
foreach (Outlook.MAPIFolder searchFolder in searchFolders)
{
if (searchFolder.Name == viewName)
{
newView = inBox.Folders[viewName];
foundView = true;
}
}
if (!foundView)
{
newView = (Outlook.MAPIFolder)inBox.Folders.
Add("HtmlView", Outlook.OlDefaultFolders.olFolderInbox);
newView.WebViewURL = "https://www.microsoft.com";
newView.WebViewOn = true;
}
Application.ActiveExplorer().SelectFolder(newView);
Application.ActiveExplorer().CurrentFolder.Display();
}
See Also
Tasks
How to: Programmatically Retrieve a Folder by Name
How to: Programmatically Create Custom Folder Items