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

Free Support Forum - aspose.com

Get MSG property by property's hex name

Oops, I found the namespace. Sorry about the previous post.

Dear becky,

Thanks for your post.

Please share your idea about the beta2. Therefore, we will release the product shortly.

Hi there,

I was doing some testing on Beta2 and found the following so far:

    1. Date Mapi Properties: I am using the following code to get values of date properties, the value “Dec, 31, 1960” always gets returned for any date properties:

MapiProperty sentDateProperty = (MapiProperty)msg.Properties[MapiPropertyTag.PR_CLIENT_SUBMIT_TIME];

string sentDate = sentDateProperty.GetDateTime().ToLongDateString();

    1. The MapiMessage.Recipients collection: I was thinking to get sender info from this collection since there is a MapiRecipientType.MAPI_SUBMITTED defined. Is the sender supposed to be in this collection?

    1. I was running the attached msg file, and got the following error while the MapiMessageReader is trying to read this msg. I can open it in outlook fine.

    {"In storage can not be found stream with specified name: __substg1.0_3701000D"}

    1. I see Ole objects embedded objects are included in the MapiAttachmentCollection, can you provide a way to differentiate the Ole objects with the attachments?
    2. I didn’t find the saving to mht function in the Beta, is it coming in the May release?

Hi,

1. I have fixed the bug in GetDateTime, which will lead to the wrong date.

2. For the recipient collection contains the detail information about sender like sender type, address. The senders are all in recipient collection

3. A new property called MapiObjectProperty is added. If an attachment contains an Ole object, its DataObject property will not be null.

4. We can only provide limited Mht saving function in May, including TextBody, Attachment (No Ole object).

MapiAttachment att = message.Attachments[0];
MapiObjectProperty obj = (MapiObjectProperty)att.Properties[MapiPropertyTag.PR_ATTACH_DATA_OBJ];

MapiMessage mesg = MapiMessage.FromProperties(obj.Properties);

Console.WriteLine(mesg.Subject);

Check out the fixes

http://www.aspose.com/products/Aspose.Network/Demos/Aspose.Network%203.5%20beta3.zip

Thanks for these fixes, I will try them out soon. Were you able to reproduce the error while loading the attached msg (in my previous post) in to Aspose? It has embedded excel spreadsheet, I was guessing that was the problem.

Thanks!

Were you guys able to to reproduce the error from the embedded excel spreadsheet?


Thanks for your considering Aspose.Network.

This bug does not cause by the embedded excel spreadsheet. It is because the embedded Msg messages. We have fixed it in the latest release by adding a new class MapiObjectProperty to parse the embedded message.

MapiAttachment att = message.Attachments[0];
MapiObjectProperty obj =

(MapiObjectProperty)att.Properties[MapiPropertyTag.PR_ATTACH_DATA_OBJ];

MapiMessage mesg = MapiMessage.FromProperties(obj.Properties);

Console.WriteLine(mesg.Subject);

Thanks,

Thanks! I was able to load the test message and get the MapiMessage through MapiObjectProperty. What I want to do next is to save this MapiMessage as a msg. Is this function available?

I tried the new release (as well as Beta 3), and I think the Date properties are still showing the wrong dates, can you please verify?

I also tried the MapiRecipientCollection, still can't find the from person in the MapiRecipientCollection. can you please verify?

About extracting attachments, I have the following points I want to verify with you:

  1. If the attachment is a msg, I will need to use the following code to "re-create" the msg:

MapiObjectProperty obj = (MapiObjectProperty)att.Properties[MapiPropertyTag.PR_ATTACH_DATA_OBJ];

MapiMessage mesg = MapiMessage.FromProperties(obj.Properties);

can I safely assume if the MapiObjectProperty I get from the above code is NOT null, then this attachment is a msg, and if the MapiObjectProperty IS null, then this attachment is either ole or regular file attachment?

2. To determine if an attachment is an ole, can I rely on ObjectData property of the attachment, if it is NOT null, then that means, it is ole.

3. If the attachement is either ole or msg, then it is a regular file attachment.

About extracting Ole embedded object, I have the following questions:

1. Are you looking to support rendering Ole object when saving msg to mht in the June release?

2. Are you looking to support extracting Ole object, and provide the ability to save it to as a valid file? Our focus right now is to be able to extract embedded MS office files and pdf. The type of Ole objects we are looking to extract are those represented by an Icon (when you double click the icon, the document underneath the icon will open).

Thank you!

See my inline comment.

Thanks! I was able to load the test message and get the MapiMessage through MapiObjectProperty. What I want to do next is to save this MapiMessage as a msg. Is this function available?

[We do not support Save to Msg file. However, MailMessage.Save supports rendering to Eml/Mht. In the latest beta, we support to render the embedded Msg files to the Eml attachment. The embedded Msg is also converted to eml format. ]

I tried the new release (as well as Beta 3), and I think the Date properties are still showing the wrong dates, can you please verify?

[Could you give me more detail about this bug? I cannot reproduce it.]

I also tried the MapiRecipientCollection, still can't find the from person in the MapiRecipientCollection. can you please verify?

[The recipients do not contain the From person. Please use the Sender property of the MapiMessage. Only Cc, Bcc, To in the recipients of the MapiMessage.]

About extracting attachments, I have the following points I want to verify with you:

  1. If the attachment is a msg, I will need to use the following code to "re-create" the msg:

MapiObjectProperty obj = (MapiObjectProperty)att.Properties[MapiPropertyTag.PR_ATTACH_DATA_OBJ];

MapiMessage mesg = MapiMessage.FromProperties(obj.Properties);

can I safely assume if the MapiObjectProperty I get from the above code is NOT null, then this attachment is a msg, and if the MapiObjectProperty IS null, then this attachment is either ole or regular file attachment?

[Yes, if the attachment type is normal attached file type, its BinaryData will be NOT null. Otherwise, it will be null and ObjectData is not null. But I am not sure whether the ObjectData is always a Msg file. I will follow up this question and get back to you soon.]

2. To determine if an attachment is an ole, can I rely on ObjectData property of the attachment, if it is NOT null, then that means, it is ole.

[Yes, if the ObjectData is not null, the attachment is an Ole.]

3. If the attachement is either ole or msg, then it is a regular file attachment.

[Not sure, I will follow up this.]

About extracting Ole embedded object, I have the following questions:

[Do you mean the object in the attachment ? If you mean the embedded Msg files in attachment, Yes, we have support this. Please download the latest hotfix.]

[If you mean the embedded Ole in the mail body, let's say a excel chart image. We do not support now. It is embedded in the Rtf formatted body. We are still developping the Rtf parsing and rendering engine. The latest hotfix does have a simple Rtf parsing engine, however, it cannot handle this.]

1. Are you looking to support rendering Ole object when saving msg to mht in the June release?

2. Are you looking to support extracting Ole object, and provide the ability to save it to as a valid file? Our focus right now is to be able to extract embedded MS office files and pdf. The type of Ole objects we are looking to extract are those represented by an Icon (when you double click the icon, the document underneath the icon will open).

[Could you provide me a sample Msg? I am not sure if I get your idea right]

Latest Hotfix:

http://www.aspose.com/products/Aspose.Network/Releases/Aspose.Network3.5.0.5.zip

  • fixed a bug in multi-language
  • add support to import Rtf body to Htmlbody
  • add support to convert embedded Msg file to Eml attachment in MailMessage.Save

Hi,

I ran into the the following exception:

error message:

"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

stack trace:

"at Aspose.Network.Win32.xbf269064be133500.x408f4b7efc86fd49(UInt32 xf8301ea65137c849)\r\n at Aspose.Network.Outlook.x72bed732dd9d7d92.Close()\r\n at Aspose.Network.Outlook.x72bed732dd9d7d92.Dispose()\r\n at Aspose.Network.Outlook.MapiMessageReader.Dispose(Boolean disposing)\r\n at Aspose.Network.Outlook.MapiMessageReader.Finalize()"

What's your code and Msg files? It works fine here.

The link I sent your yestoday is a bad dll. I have rebuilt it. Please download again using the same url

It is a beta build. Our tester is working to execute the full test pass before we publish an official build.

Thanks,

1. The date issue: I have the following code, the date I got is always {12/31/1600 7:00:00 PM}, no matter what message I load.

MapiProperty sentDateProperty = msg.Properties[MapiPropertyTag.PR_CLIENT_SUBMIT_TIME];

emailDoc.SentDate = sentDateProperty.GetDateTime();

2. Save embedded msg: I create the MapiMessage object from MapiObjectProperty object. How can I load MapiMessage to MailMessage (I see MailMessage.Save() can save to msg format as well, but don't know how to convert MapiMessage to MailMessage)? We will need to functionality to save embedded msg to disk as a msg file, are you looking to support it?

3. Differentiate between OLE and embedded msg: is there a way to do that? can you provide properties like "IsOle" or "IsEmbeddedMsg"?

4. Save MapiMessage to mht: can you show me how to do that?

5. Render ole embedded objects in mht: do you think it will be available in the June release? Please see the attached msg, can we render all of the email body in mht (so you can see the two tables and the icon in the mht)?

6. File embedded as Icon: please see the attached msg, is there a way we can retrieve the file underneath the icon?

1. This bug is fixed. I made a mistake before, however, I fixed it anyway.

2. We read the contents of embedded object to MapiObjectProperty.Data (byte[]). You can use it to save the embedded content locally. However, for the reason that the embedded Outlook message loses its property header information. You can not open it in Microsoft Outlook even save it to local file system. (We are still working on how to fix it.) For word/excel, you can save and open it locally.

using (FileStream fs = File.OpenWrite(path))

{

fs.Write(MapiObjectProperty.Data);

}

3. I added a new method to MapiObjectProperty, named IsOutlookMessage. It indicates whether the embedded object is an Outlook message.

4. We do not provide MapiMessage -> MailMessage now. (We will do this in coming release). But you can use MailMessage.Load(path, MessageFormat.Msg) to load a Msg file. By MailMessage.Save(path, MessageFormat.Eml), you can save it to eml or Mht. But saving to Msg is not supported now.

5. The embedded object in mht cannot available in short term. Because it has many dependencies, like Excel worksheet to Html.

6. This is supported. The embedded file is in the attachments of message document. Use MapiObjectProperty.Data to save it locally is possible.

PS:

We add a new feature in MailMessage.Save(path, MessageFormat.Eml). If any embedded Outlook message in it, we will convert them into Eml format attachment.

I tried to save msg to mht using MailMessage.Save(), the mht generated was pretty much empty, please see the attached.

Here is my code:

MailMessage message = new MailMessage();

MailMessage.Load(inputPath, MessageFormat.Msg);

message.Save(outputFilePath, MessageFormat.Mht);

Thanks!

Thanks for the information.

  • What version of the dll are you using?
  • Send me your msg file that your loading, if possible.

We are now still working on the format export improvement, including Rtf to Html rendering engine and Outlook message to Mht engine.

I am using Aspose.Network 3.5.1.0.

Please see the attachmed msg.

Here is another issue with converting to mht: when I try to save the attached msg to mht, the following error throws:

System.FormatException: Input string was not in a correct format.

at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)

at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)

at System.Int32.Parse(String s)

at Aspose.Network.Rtf.x66a12b1255ab95ec.x8b02636f5e98fd12(String x3c811436980dcf17)

at Aspose.Network.Rtf.x66a12b1255ab95ec.xfd2cb6c59825d443(Char xb331f69dfb16a7b0)

at Aspose.Network.Rtf.x66a12b1255ab95ec.processData()

at Aspose.Network.Outlook.x613e06a8273cafef.xf2d61a27165f149e(MailMessage xd7e5673853e47af4, MapiMessage xa773d6b986f6bdbb)

at Aspose.Network.Outlook.x613e06a8273cafef.x0985be1e7f6e03c9()

at Aspose.Network.Mail.MailMessage.Load(String fileName, MessageFormat format)

1. Thanks for fixing the date bug. One question though, I thought the date Mapi properties would always return GMT, I noticed that the date returned is actaully taken the time zone into consideration. Is there a way to get the original GMT?

2. So for OLE embedded file, only Word and Excel can be properly extracted?

3. I saved the embedded msg as a msg file, and got exception while loading it to MapiMessage. Is it caused by the header problem you mentioned in your post? As this is an important functionality for us, can you let us know the progress of fixing this issue?

4. Rendering image in mht. Is this going to be supported, for example, if I paste a picture into msg, would the picture get rendered?

5. Rendering embedded objects in mht: this breaks down to two scenarios, one is you can see the object content in the msg (for example, you insert an Excel worksheet in the msg and you can see the cells directly in the msg). the other scenario is that you inserted an object as an Icon, in this case, only the icon needs to be rendered. Can these functionality be delivered in the near future, this is quite important to us as well.

Thank you!

First for your previous 2 posts:

1. the HtmlEmail.msg you sent me can be exported good in my latest dll. Please check the attached dll and mht

2. this bug is in the Rtf->Html render engine, we will fix it as soon as possible.

Second for your questions:

1. pending to follow up

2. Except the embedded Outlook message file, most of the Ole files can be extracted properly.

3. I will add some fix for this issue, therefore, the extracted embedded message file will be able to load by MailMessage class

4. pending to follow up. need investigation

5. could you give me a sample for scenario 2? It looks like 4. Basically, if it is simple, we can render it into html.

Can we talk about the features on MSN. We can prioritize some of the working items. Therefore, both of us can get a deliverable item in right time.

Thanks,