Free Support Forum - aspose.com

Delete folder from exchange server


#1

I want to create a folder on exchange server, and to create a new one if folder already exist after deleting the existing one.

My code is as:

try
{
client.FolderExists(rootUri, rootfolder, out tempfolder);
if (tempfolder == null)
{
rootex = client.CreateFolder(rootUri, rootfolder);
client.ListSubFolders(rootUri);
}
else
{
if (MessageBox.Show(“File Already Exists, Want to replace Existing File?”, “Duplicate File”, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
break;
else
{
string tempuri = tempfolder.Uri;
client.DeleteFolder(tempuri);
MessageBox.Show("Existing Folder Deleted ");
rootex = client.CreateFolder(rootUri, rootfolder);
MessageBox.Show("New Folder created ");
client.ListSubFolders(rootUri);
}
}

please help me, how can I achieve the same.


#2

@ritadcc126,

I have observed your requirements and suggest you to please try using following sample code.

            // connect to gmail server
            Aspose.Email.Clients.Imap.ImapClient imap = new Aspose.Email.Clients.Imap.ImapClient("imap.gmail.com", 993, "xxxx@gmail.com", "pas");

            // create new folder
            imap.CreateFolder("Test Folder/SubFolder");
            //   imap.cre
            // select New Folder
            imap.SelectFolder("Test Folder/SubFolder");

            imap.DeleteFolder("Test Folder/SubFolder");

            imap.CreateFolder("Test Folder/SubFolder");