Problem loading Msg File

I have downloaded the latest 3.5 version and tries to import a .msg file. The files htmlbody data is blank. However there is some data in the textbody. Will it work anytime soon to import msg files with html body?

Best regards Henrik

Please use MapiMessage to parse the Msg file, if you want to get more information from the document. Because msg file only contains Rtf format body and Text format body. MailMessage does not support import the Rtf format to Html format body. So you get empty in the htmlbody property.

However, we are now working on the Rtf to Html feature. It will be availble in the comming release.

[VB]

Dim message As MapiMessage

'load and parse the Microsoft Outlook Message files
Imports (MapiMessageReader mr = New MapiMessageReader("c:\sample.msg"))
{
message = mr.ReadMessage()
}

'read subject property. Or you can use MapiMessage.Subject too.
Dim subject As String = message.GetPropertyString(MapiPropertyTag.PR_SUBJECT)

'read body property. Or you can use MapiMessage.Body too.
Dim body As String = message.GetPropertyString(MapiPropertyTag.PR_BODY)

Console.WriteLine("subject:"+subject)
Console.WriteLine("Body:" + body)

'read internet code page property.
Dim prop As MapiProperty = message.Properties(MapiPropertyTag.PR_INTERNET_CPID) as MapiProperty
If Not prop Is Nothing Then
Console.WriteLine("CodePage:" + prop.GetLong())
End If
[C#]

MapiMessage message;

//load and parse the Microsoft Outlook Message files
using (MapiMessageReader mr = new MapiMessageReader(@"c:\sample.msg"))
{
message = mr.ReadMessage();
}

//read subject property. Or you can use MapiMessage.Subject too.
string subject = message.GetPropertyString(MapiPropertyTag.PR_SUBJECT);

//read body property. Or you can use MapiMessage.Body too.
string body = message.GetPropertyString(MapiPropertyTag.PR_BODY);

Console.WriteLine("subject:"+subject);
Console.WriteLine("Body:" + body);

//read internet code page property.
MapiProperty prop =
message.Properties[MapiPropertyTag.PR_INTERNET_CPID] as MapiProperty;
if (prop != null)
{
Console.WriteLine("CodePage:" + prop.GetLong());
}

Hi, We have released a beta version of Aspose.network.

In this release, the Rtf body is converted to Htmlbody. Please check it out.

[http://www.aspose.com/products/aspose.network/releases/Aspose.Network3.5.0.5.zip](https://forum.aspose.com/products/aspose.network/releases/Aspose.Network3.5.0.5.zip)

I have retrieved the html body through using the MAPI property like: So you do not need trying convert the rtf body value for version > 2002 I think.

Dim mr As New Aspose.Network.Outlook.MapiMessageReader(sFileName)

mm = mr.ReadMessage()

mr.Dispose()

Private Const PR_HTML As Long = 269680898

Dim b As Byte() = mm.GetPropertyBytes(PR_HTML)

If Not b Is Nothing Then

Dim ms As New System.IO.MemoryStream(b)

Dim sr As New System.IO.StreamReader(ms, System.Text.UnicodeEncoding.Default)

msg.HtmlBody = sr.ReadToEnd()

End If

I would need a .Net 1.1 version to for production unfortunately..

Thanks for your considering.

We will release an official build soon, which will contain .Net 1.1 version and .Net 2.0 version dll.

Hi, We have released a new version of the Aspose.Network (with 1.1 and 2.0 builds).

Please check it out.

http://www.aspose.com/Downloads/Components/Default.aspx