Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#3.0 Outlook
Hi,
 
I am creating sub folders inside the inbox folder using following code.
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.
Cry | :(( D'Oh! | :doh:
Posted 12-Jun-10 4:46am
Edited 12-Jun-10 7:32am
v7

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

  Print Answers RSS
0 OriginalGriff 304
1 Sergey Alexandrovich Kryukov 255
2 Shweta N Mishra 216
3 Maciej Los 210
4 PIEBALDconsult 184
0 OriginalGriff 7,630
1 Sergey Alexandrovich Kryukov 7,022
2 DamithSL 5,586
3 Manas Bhardwaj 4,946
4 Maciej Los 4,525


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 12 Jun 2010
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100