This documentation is archived and is not being maintained.

How to: Move Items in Outlook

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


    Visual Studio Team System

  • Microsoft Office Outlook 2003


This code does not compile if you use the VSTO 2005 SE version of the Outlook 2003 add-in project template. For more information, see Getting Started Programming Application-Level Add-ins.

This example moves unread e-mail messages from the Inbox to a folder named Test. The example only moves messages that have the word Test in the Subject field.


private void ThisApplication_Startup(object sender, System.EventArgs e)
    this.NewMail += new Microsoft.Office.Interop.Outlook.


private void ThisApplication_NewMail()
    Outlook.MAPIFolder inBox = (Outlook.MAPIFolder)this.
    Outlook.Items items = (Outlook.Items)inBox.Items;
    Outlook.MailItem moveMail = null;
    items.Restrict("[UnRead] = true");
    Outlook.MAPIFolder destFolder = inBox.Folders["Test"];
    foreach (object eMail in items)
            moveMail = eMail as Outlook.MailItem;
            if (moveMail != null)
                string titleSubject = (string)moveMail.Subject;
                if (titleSubject.IndexOf("Test") > 0)
        catch (Exception ex)

Compiling the Code

This example requires:

  • An Outlook mail folder named Test.

  • An e-mail message that arrives with the word Test in the Subject field.

See Also