Click here to Skip to main content
15,891,423 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am creating sub folders inside the inbox folder using following code.
C#
private void btnCreate_Click(object sender, EventArgs e)
{
    if (string.IsNullOrEmpty(txtInboxFolderName.Text.Trim().ToString()))
    {
        MessageBox.Show("Enter name of the folder", "Null value", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
        txtInboxFolderName.Focus();
        return;
    }
    else
    {
        CreateNewInboxFolder();
    }
}

private void CreateNewInboxFolder()
{
    try
    {
        string folderName = txtInboxFolderName.Text.ToString();
        OutLook._Application olApp = new OutLook.ApplicationClass();
        OutLook._NameSpace olNs = olApp.GetNamespace("MAPI");
        OutLook.MAPIFolder oInbox = olNs.GetDefaultFolder(OutLook.OlDefaultFolders.olFolderInbox);
        OutLook.Folders oFolders = oInbox.Folders;
        OutLook.MAPIFolder oInboxFolders = oFolders.Add(folderName, OutLook.OlDefaultFolders.olFolderInbox);
        MessageBox.Show("Folder " + oInboxFolders.Name + " is Created", "Create inbox folder", MessageBoxButtons.OK, MessageBoxIcon.Information);
    }
    catch (Exception)
    {
        MessageBox.Show("Folder name: " + txtInboxFolderName.Text +" is already created" + "\nPlease enter different folder name",
            "Error",
            MessageBoxButtons.OK,
            MessageBoxIcon.Exclamation);
        txtInboxFolderName.Focus();
    }
}

From the above code I can create sub folder inside the Inbox folder. Then what I need to do is save the e-mail into that created folder. Please help me to do it.

I think we can import those folder names to a separate form and select one from there, then I can save e-mails (e-mail datails is in the data grid and I need to save them to new folder)

Please help me with the code.

I am very confused and I'm not sure how to do it.
:(( :doh:
Posted
Updated 12-Jun-10 6:32am
v7

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900