Thanks for the sample file.
Here is a code example, that gets you to the underlying byte array, and allows you to use any Encoding sheme you want to decode the byte array.
static void BlakeSmith2()
{
string path = @"C:\temp\FunnyCharacters\FunnyCharacters.eml";
MimeMessage m= MimeMessage.ParseFile( path );
TnefMessage tnef = m.TnefMessage();
byte[] data = FindHtmlBinary(tnef);
if( data != null )
{
string s = Encoding.UTF8.GetString( data );
StreamWriter sw= new StreamWriter( "c:\\temp\\blake2.html");
sw.Write( s );
sw.Flush();
sw.Close();
}
}
static byte[] FindHtmlBinary(TnefMessage tnef)
{
byte[] data = null;
ArrayList properties = tnef.FindMapiProperties( MapiAttribute.PR_HTML, true );
if( (properties != null ) && ( properties.Count > 0 ) )
{
for( int i=0;i<properties.Count;i++)
{
MapiProperty prop = properties[ i ] as MapiProperty;
if( (prop != null) && ( prop.Value != null ) )
{
data = (byte[])prop.Value;
return data;
}
}
}
return data;
}
Let me know if you need anything else,
Dave
|