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

Free Support Forum - aspose.com

How to Convert PT_BINARY Property to String Values?

<o:shapedefaults v:ext=“edit” spidmax=“1026” />

<![endif]–><!–[if gte mso 9]>

<o:shapelayout v:ext=“edit”>

<o:idmap v:ext=“edit” data=“1” />


Hi –

I am testing Aspose Network to read msg files. I am getting all MapiProperties and building string values for each. I am stuck on PT_BINARY. How do I convert those to String values. I have tried System.Convert and different Encodings. I am also doing all of this in C#.



This message was posted using Email2Forum by ShL77.

Hi Joey,

Thanks for considering Aspose.

The MAPI property of type PT_BINARY contain byte array (http://www.aspose.com/documentation/.net-components/aspose.network-for-.net/aspose.network.outlook.mapipropertytype.html).

You may use Encoding.GetString() kind of method similar to the below code sample:
MapiMessage message = MapiMessage.FromFile("Email.msg");
MapiPropertyCollection propColl = message.Properties;
foreach (MapiProperty mapiprop in propColl.Values)
    if (mapiprop != null)
        Console.WriteLine("Name: " + mapiprop.PropertyTagName + ", Type: " + mapiprop.DataType);
        switch (mapiprop.DataType)
            case (int)MapiPropertyType.PT_STRING8:
                //Console.WriteLine("String value: " + mapiprop.GetString());
            case (int)MapiPropertyType.PT_BINARY:
                Console.WriteLine("Binary value: " + System.Text.UTF8Encoding.UTF8.GetString(mapiprop.Data));