Microsoft Office Tutorials and References
In Depth Information
Manipulation
We can see the dynamically-created folder named FolderPacktPub o n the leftmost
side of the Outlook screen, as shown in the following screenshot:
The folders contain Items collections which hold items that are compatible
with the type of data that is supported in Microsoft Office Outlook 2007. The
GetDefaultFolder() method is used to retrieve a reference to the Sent Items
folder. This is declared in order to get default folders by using new Folder
objects for Outlook 2007.
You may need to clean up Outlook by deleting unwanted folders. The delete
operation for folders inside Outlook can be performed by using the MAPIFolder
object and the properties and methods exposed by the object. Let's see an example of
how to delete a folder using the VSTO object. In this example, you are going to run
the operation at the initialization of the add-in. You can do the same thing by using
the Click event for the button that was placed on the toolbar (or anywhere else
you need).
Open Visual Studio 2008 and create a new solution, as explained earlier. Write the
following code, which will dynamically delete a folder in the ThisAddIn.cs file:
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
// Loading the NameSpace needed to manipulate MAPI
Outlook.NameSpace PacktNameSpace = this.Application.
GetNamespace("MAPI");
// Accessing the folder through MAPIFolder Object
 
Search JabSto ::




Custom Search