How to create a new folder in microsft outlook using Aspose.Email

Hi,

How to create a new folder in microsft outlook using Aspose.Email .I need to move some mails to this newly created folder.How can i do it?

Thanks & Regards,

Brijesh

Hi Brijesh,

Thank you for using Aspose.Email.

Please have a look at the following code which creates a sub-folder in the Inbox folder and then moves a message from the inbox folder to this new folder. Please feel free to contact us if you have any additional query.

const string mailboxUri = “[https://exchange.test.com/ews/Exchange.asmx ](https://exchange.test.com/ews/Exchange.asmx)”;

const string domain = @"";

const string username = @"username";

const string password = @"password";

Console.WriteLine("Connecting to Exchange Server....");

NetworkCredential credential = new NetworkCredential(username, password, domain);

ExchangeWebServiceClient client = new ExchangeWebServiceClient(mailboxUri, credential);

ExchangeMailboxInfo mailboxInfo = client.GetMailboxInfo();

//create a new folder

client.CreateFolder(mailboxInfo.InboxUri, "TestInbox");

//Declare variable for getting specified custom folder uri

ExchangeFolderInfo subfolderInfo = new ExchangeFolderInfo();

//Check if specified custom folder exisits

client.FolderExists(mailboxInfo.InboxUri, "TestInbox", out subfolderInfo);

// List all messages from Inbox folder

Console.WriteLine("Listing all messages from Inbox....");

ExchangeMessageInfoCollection msgInfoColl = client.ListMessages(mailboxInfo.InboxUri);

//Move the first item from inbox to this test folder

ExchangeMessageInfo msgInfo = msgInfoColl[0];

client.MoveItem(msgInfo.UniqueUri, subfolderInfo.Uri);