Quantcast
Channel: Aspose.Email Product Family
Viewing all articles
Browse latest Browse all 1367

Folder DisplayName contains backslash

$
0
0
Hi,

we're copying PST file structure from file A to file B while we try to preserve the folder structure. That includes the RootFolder name of the PST (I do know this isn't visible to the user, but we require that).

Testing with a German ANSI PST file we get the name of the root folder containing unexpected backslash.

Here is a sample code we're using:

static void Main(string[] args)
{    new License().SetLicense("Aspose.Email.lic");    if (args.Length != 1)    {        Console.WriteLine("Usage: {0} <source pst file>"AppDomain.CurrentDomain.FriendlyName);        return;    }    using (var pst = PersonalStorage.FromFile(args[0], false))    {        Console.WriteLine("PST File [{0}] - [{1}]", args[0], pst.IsUnicode ? "Unicode" : "ANSI");        GetFolderNames(pst.RootFolder, pst.IsUnicode);        GetFolderNames(pst.GetPredefinedFolder(StandardIpmFolder.DeletedItems), pst.IsUnicode);        GetFolderNames(pst.GetPredefinedFolder(StandardIpmFolder.Inbox), pst.IsUnicode);    }
}private static void GetFolderNames(FolderInfo folder, bool isUnicode)
{    if (folder == null)    {        return;    }    var displayName = folder.DisplayName;    var containsBackslash = displayName.Contains(@"\");    var displayNameProp = isUnicode ? 
folder.Properties[MapiPropertyTag.PR_DISPLAY_NAME_W] :
folder.Properties[MapiPropertyTag.PR_DISPLAY_NAME_A];    var convertedAscii = Encoding.ASCII.GetString(displayNameProp.Data);    var convertedDefault = Encoding.Default.GetString(displayNameProp.Data);    Console.WriteLine("PST Folder [{0}] - [\\ {1}found] - ASCII [{2}] - Default [{3}]",
displayName, containsBackslash ? string.Empty : "NOT ",
convertedAscii, convertedDefault); }
The output of that looks like this:

PST File [ansi_german_file.pst] - [ANSI]
PST Folder [Oberste Ebene des Pers\'F6nlichen Ordners] - [\ found] - ASCII [Oberste Ebene des Pers?nlichen Ordners] - Default [Oberste Ebene des Persönlichen Ordners]
PST Folder [Gel\'F6schte Objekte] - [\ found] - ASCII [Gel?schte Objekte] - Default [Gelöschte Objekte]
PST Folder [Inbox] - [\ NOT found] - ASCII [Inbox] - Default [Inbox]

We're not sure how the DisplayName is retrieved but I suspect it shouldn't contain backslash as it's separator. Also, retrieval of the value directly from the MapiProperty gives better results (especially the "Default" one). Is this something that is "codepage" related?

I'm attaching the ANSI sample PST file (in ZIP).

Best regards,
Michal

Viewing all articles
Browse latest Browse all 1367

Trending Articles