How to get email body from pst for specific entityId

Hi,

I’ve to process fairly big pst and I need to extract subject and body of the email.
I’m able to find the subject property using the pst.ExtractProperty method but i’m unable to find the property id matching the mail body.

I only find a subset of the text but I need the full body. (i’m ok with the text only body)

I managed to get the body extracting the msg but it is time consuming and if possible I’d prefer to access the specific property.

Anyone can help?

Hello @Scooter12345,

Welcome to our support forum!

To extract the body property by PR_BODY_W property tag (0x1000001F), you can use the following:


foreach (var enrtyId in folder.EnumerateMessagesEntryId())
{
    // Get the body property by 0x1000001F tag value. 
    var body = pst.ExtractProperty(Convert.FromBase64String(enrtyId),
        MapiPropertyTag.PR_BODY_W).GetString();;
}

The example above works for Unicode PST. However, keep in mind if you are reading
ANSI PST, you should use the appropriate PR_BODY_A tag (0x1000001E) for the body property:


if (!pst.IsUnicode)
{
    foreach (var enrtyId in folder.EnumerateMessagesEntryId())
    {
	    // Get the body property by 0x1000001E tag value.
        var body = pst.ExtractProperty(Convert.FromBase64String(enrtyId),
            MapiPropertyTag.PR_BODY_A).GetString();;
    }
}