We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Copy Email to SubFolder

Hello,
i like to move my email to subfolder. The path is : Test/Test1/Test11
then i want to move my email from inbox to Test11
How kann i access to Test11 ?

String folderName=“Test”;
ExchangeFolderInfo folderInfo=new ExchangeFolderInfo();
client.FolderExists(client.MailboxInfo.RootUri, folderName, out FolderInfo);

its possible to access to Test but its not possible to access to Test11;
help Please

Best regards,
Nacata

Hi Nacata,


I am afraid that I could not find any method which can directly provide the uri of sub folder in the hierarchy. However following is a sample code which can be used to get the uri of Test11 from path Inbox\Test\Test1\Test11. Please give it a try and let us know your feedback.

public static void TestExchangeFolders()
{
IEWSClient client = GetAsposeEWSClientTest3();

ExchangeFolderInfo info = new ExchangeFolderInfo();
string TargetFolderUri = SearchSubFolder(client, client.MailboxInfo.InboxUri, “Test11”);
}

public static string SearchSubFolder(IEWSClient client, string parentFolder, string TargetFolder)
{
ExchangeFolderInfoCollection coll = client.ListSubFolders(parentFolder);
foreach(ExchangeFolderInfo info in coll)
{
if (info.DisplayName == TargetFolder)
return info.Uri;
else
{
string result = SearchSubFolder(client, info.Uri, TargetFolder);
if (result != null)
{
return result;
}
}
}
return null;
}