How to: Determine the Parent Folder of Unsaved Items
Applies to |
---|
The information in this topic applies only to the specified Visual Studio Tools for Office projects and versions of Microsoft Office. Project type
Microsoft Office version
For more information, see Features Available by Application and Project Type. |
This example determines the parent MAPIFolder of an unsaved contact item.
Example
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)
MessageBox.Show(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);
}
See Also
Tasks
How to: Retrieve a Folder by Name
How to: Search for a Specific Contact
How to: Add an Entry to Outlook Contacts