HOW TO:判斷未儲存項目的父資料夾
這個範例會判斷未儲存連絡人項目的父 MAPIFolder。
**適用於:**本主題中的資訊適用於 Outlook 2007 和 Outlook 2010 的應用程式層級專案。如需詳細資訊,請參閱依 Office 應用程式和專案類型提供的功能。
範例
Private Sub ThisAddIn_Startup(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Me.Startup
Dim contact As Outlook.ContactItem = _
Me.Application.CreateItem(Outlook.OlItemType.olContactItem)
Dim folder As Outlook.MAPIFolder = _
TryCast(contact.Parent, Outlook.MAPIFolder)
MsgBox(folder.Name)
End Sub
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
Outlook.ContactItem contact =
this.Application.CreateItem
(Outlook.OlItemType.olContactItem)
as Outlook.ContactItem;
Outlook.MAPIFolder folder =
contact.Parent as Outlook.MAPIFolder;
MessageBox.Show(folder.Name);
}